Commit 352e83c
fix(site-url): 拿掉 prod 硬编码 fallback,env 缺失生产即抛错
之前 lib/site-url.ts 用 '?? "https://involutionhell.com"' 做兜底,违反
docs/architecture/frontend-backend-separation.md:96-103 "生产环境不做硬编码 fallback" 的约定。
在 preview/staging 漏配 NEXT_PUBLIC_SITE_URL 时会静默产出指向 prod 域的 sitemap/robots,
这正是文档警告的"漏配变静默错地址"。
新策略走 resolveSiteUrl():
- env 非空 → normalizeSiteUrl 返回
- NODE_ENV === 'production' 且 env 缺失 → throw,构建/启动失败(intentional)
- 其它(dev/test)→ fallback http://localhost:3000(和 next start -p 3000、
OAuth 回调、next.config.mjs rewrites 的 localhost:3000 约定对齐)
robots / sitemap 继续 import { SITE_URL },无变更。1 parent a3f16b9 commit 352e83c
1 file changed
Lines changed: 32 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | | - | |
21 | | - | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
38 | 60 | | |
39 | 61 | | |
40 | 62 | | |
41 | | - | |
| 63 | + | |
0 commit comments