fix(dev): devServer.allowedHosts 改为显式白名单(默认含 deepseek.xdjchuanhui.com)——修经 nginx 域名访问 dev 报 Invalid Host header,同时保持不用 'all'
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s

This commit is contained in:
Ubuntu
2026-10-20 14:33:49 +08:00
parent 54c9a0671d
commit a196401614
+10 -2
View File
@@ -137,8 +137,16 @@ module.exports = (env = {}, argv = {}) => {
port: 3021,
// OPS-7:默认只监听回环;需要局域网/手机调试时显式 `WEB_HOST=0.0.0.0`(勿默认全开)
host: process.env.WEB_HOST || '127.0.0.1',
// O-12.8:默认 'auto'(仅本机/配置的 host),不要 'all'(DNS rebinding 可借 devServer 代理打内网)
allowedHosts: 'auto',
/**
* O-12.8:不要 'all'(DNS rebinding 可借 devServer 代理打内网)。
* 但 'auto' 只信任本机 host ⇒ 经 nginx 以域名访问 dev(8443/8444)会报
* `Invalid Host header`(2026-10-20 实测)。这里改为**显式白名单**:
* 域名 + 本机;如需加主机,通过 `WEB_ALLOWED_HOSTS=a,b,c` 覆盖。
*/
allowedHosts: (process.env.WEB_ALLOWED_HOSTS || 'deepseek.xdjchuanhui.com,localhost,127.0.0.1')
.split(',')
.map((h) => h.trim())
.filter(Boolean),
// 本地预览默认 HTTPS(自签证书需浏览器点「继续访问」)
server: useDevHttps ? 'https' : 'http',
client: {