43c76fb978
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Successful in 25s
ci-pangolin / Lint — shellcheck (push) Successful in 29s
ci-pangolin / Cleartext Scan — Android 禁明文 (push) Successful in 22s
ci-pangolin / OpenAPI Sync Check (push) Successful in 40s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (push) Successful in 19s
ci-pangolin / Flutter — analyze + test (push) Failing after 4m59s
ci-pangolin / Codegen Drift — token 生成物未漂移 (push) Successful in 1m51s
ci-pangolin / DS-flow — 原型/跨端同源/代码色单源闸 (push) Successful in 5s
ci-pangolin / Go — build + test (push) Failing after 1m33s
ci-pangolin / E2E Smoke — L4 进程级端到端 (push) Failing after 14s
ci-pangolin / Go — integration (mysql/redis testcontainers) (push) Failing after 4m59s
ci-pangolin / Golden — 视觉回归 (全量:components/auth/desktop/tablet) (push) Failing after 4s
# Conflicts: # docs/index.html # server/cmd/server/main.go
53 lines
2.3 KiB
JavaScript
53 lines
2.3 KiB
JavaScript
// @ts-check
|
||
import { defineConfig } from 'astro/config';
|
||
import react from '@astrojs/react';
|
||
import { SITE } from './src/config/site.ts';
|
||
|
||
// 纯静态站点 (SSG),零 SSR。
|
||
// `site` 仅用于生成绝对 URL(sitemap / canonical),镜像部署时可被任意域名覆盖,
|
||
// 不影响「整站可秒级复制到任意备用域名」:产物为纯相对路径静态文件。
|
||
// 主站 canonical 域名。镜像构建务必用「同一个」SITE_URL,使 canonical 始终指向主站
|
||
// (避免镜像与主站 SEO 竞争),且主站/镜像产物 hash 完全一致(验收:内容一致性)。
|
||
const SITE_URL = process.env.SITE_URL || SITE.url;
|
||
|
||
export default defineConfig({
|
||
site: SITE_URL,
|
||
output: 'static',
|
||
trailingSlash: 'always',
|
||
build: {
|
||
// 内联样式/脚本会破坏严格 CSP(script-src/style-src 'self'),全部产出为独立资源文件。
|
||
inlineStylesheets: 'never',
|
||
assets: '_astro',
|
||
},
|
||
integrations: [react()],
|
||
vite: {
|
||
build: {
|
||
// 关闭 JS 内联,保证 script-src 'self' 严格 CSP 下可运行。
|
||
assetsInlineLimit: 0,
|
||
},
|
||
server: {
|
||
// /buy 本地联调测试页专用:浏览器同源调后端,避免跨域。仅 dev 生效,不影响构建产物。
|
||
//
|
||
// 坑:Astro 全站 trailingSlash:'always',dev server 对不带尾斜杠、又没有匹配页面路由
|
||
// 的路径(如 /v1/pay/catalog)会在到达这里的 vite 代理之前就短路返回 Astro 自己的 404
|
||
// (已用本地 mock 后端验证:带尾斜杠能命中此代理,不带则 404,Astro middleware 同样不触发,
|
||
// 因为它只包裹「匹配到的」路由渲染,不包裹压根没有路由匹配的任意路径)。
|
||
// 于是这里约定:BuyFlow.jsx 发请求一律带尾斜杠(`/v1/pay/catalog/` 这类,与全站
|
||
// trailingSlash 约定一致),再用 rewrite 在转发前把尾斜杠去掉,避免打到后端 chi 路由
|
||
// (未挂 StripSlashes,尾斜杠会 404)。
|
||
proxy: {
|
||
'/v1': {
|
||
target: 'http://127.0.0.1:8080',
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/\/$/, ''),
|
||
},
|
||
'/paydev': {
|
||
target: 'http://127.0.0.1:8090',
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/^\/paydev/, '/api/v2/dev').replace(/\/$/, ''),
|
||
},
|
||
},
|
||
},
|
||
},
|
||
});
|