update
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// @ts-check
|
||||
import { defineConfig, envField } from 'astro/config';
|
||||
import { defineConfig } from 'astro/config';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
@ -41,17 +41,6 @@ export default defineConfig({
|
||||
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 }),
|
||||
},
|
||||
},
|
||||
// base 地址配置已迁到 src/lib/config(dev/prod 两份 TS,缺则抛异常)。
|
||||
// 仅「密钥」类仍走构建期 env(如 SSG_TOKEN),不在此声明,也不进客户端 bundle。
|
||||
});
|
||||
Reference in New Issue
Block a user