Files
TrueGrowth/netlify.toml

104 lines
3.6 KiB
TOML

[build]
# 构建命令 - 使用 pnpm 并先重置 Nx 缓存
command = "pnpm install && pnpm nx reset && pnpm run build:web"
# 发布目录 - Nx构建的web应用输出目录
publish = "dist/apps/web"
# Node.js版本和内存设置 - 升级到 Node 20 以支持 Vite 6
environment = { NODE_VERSION = "20", NODE_OPTIONS = "--max-old-space-size=8192" }
[build.processing]
# 跳过处理,使用原始文件
skip_processing = false
[build.processing.css]
bundle = true
minify = true
[build.processing.js]
bundle = true
minify = true
# TrueModel API 同源代理,避免浏览器直连中转站时触发 CORS
[[redirects]]
from = "/api/truemodel/*"
to = "https://truemodel.benchu.cloud/:splat"
status = 200
force = true
# SPA路由重定向规则
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
# 安全头设置 - 允许特定域名iframe嵌入
[[headers]]
for = "/*"
[headers.values]
Content-Security-Policy = "default-src 'self' https: data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://www.google-analytics.com https://us.i.posthog.com https://us-assets.i.posthog.com https://wiki.tu-zi.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' data: https://fonts.gstatic.com; img-src 'self' data: blob: https:; connect-src 'self' https: wss: data: blob:; frame-ancestors 'self' localhost:* 127.0.0.1:* *.localhost:* https://truemodel.benchu.cloud;"
X-XSS-Protection = "1; mode=block"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "origin-when-cross-origin"
# HTML文件特定配置
[[headers]]
for = "/*.html"
[headers.values]
Content-Security-Policy = "frame-ancestors 'self' localhost:* 127.0.0.1:* *.localhost:* https://truemodel.benchu.cloud"
Cache-Control = "public, max-age=0, must-revalidate"
# iframe测试页面配置
[[headers]]
for = "/iframe-test.html"
[headers.values]
Content-Security-Policy = "frame-ancestors 'self' localhost:* 127.0.0.1:* *.localhost:* https://truemodel.benchu.cloud; frame-src 'self' localhost:* https://truemodel.benchu.cloud data:"
Cache-Control = "public, max-age=0, must-revalidate"
# 缓存设置
[[headers]]
for = "/static/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.js"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
Content-Security-Policy = "frame-ancestors 'self' localhost:* 127.0.0.1:* *.localhost:* https://truemodel.benchu.cloud"
[[headers]]
for = "/*.css"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
Content-Security-Policy = "frame-ancestors 'self' localhost:* 127.0.0.1:* *.localhost:* https://truemodel.benchu.cloud"
# Service Worker特殊配置
[[headers]]
for = "/sw.js"
[headers.values]
Cache-Control = "public, max-age=0, must-revalidate"
Content-Security-Policy = "frame-ancestors 'self' localhost:* 127.0.0.1:* *.localhost:* https://truemodel.benchu.cloud"
# 版本信息 - 不缓存,确保总是获取最新版本
[[headers]]
for = "/version.json"
[headers.values]
Cache-Control = "public, max-age=0, must-revalidate"
[[headers]]
for = "/changelog.json"
[headers.values]
Cache-Control = "public, max-age=0, must-revalidate"
# 部署上下文配置
[context.production]
command = "pnpm install && pnpm nx reset && pnpm run build:web"
[context.deploy-preview]
command = "pnpm install && pnpm nx reset && pnpm run build:web"
[context.branch-deploy]
command = "pnpm install && pnpm nx reset && pnpm run build:web"