@ -1,5 +1,5 @@
|
||||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
import { defineConfig, envField } from 'astro/config';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
@ -39,5 +39,19 @@ export default defineConfig({
|
||||
|
||||
adapter: node({
|
||||
mode: 'standalone'
|
||||
})
|
||||
}),
|
||||
|
||||
// 环境变量声明:统一命名规范
|
||||
// BASE_API —— 公开/运行期 API 基址(浏览器 + 按需渲染共用,空 = 同源 /api)
|
||||
// BASE_API_SSG —— 构建期 SSG 内部端口基址(仅服务端,绝不进前端 bundle)
|
||||
// SSG_TOKEN —— SSG 内部接口可选访问令牌(仅服务端)
|
||||
// 注意:Astro 仅自动把 PUBLIC_ 前缀变量暴露给客户端,BASE_API 没有该前缀,
|
||||
// 故必须在 schema 中声明为 access:'public',否则浏览器端 import.meta.env.BASE_API 为 undefined。
|
||||
env: {
|
||||
schema: {
|
||||
BASE_API: envField.string({ context: 'client', access: 'public', optional: true }),
|
||||
BASE_API_SSG: envField.string({ context: 'server', access: 'secret', optional: true }),
|
||||
SSG_TOKEN: envField.string({ context: 'server', access: 'secret', optional: true }),
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user