chore: 稳定版实例 stable.sh(.stable/ 入 ignore)+ vite preview 宿主白名单

./stable.sh 起一份稳定版(:8790 / :5180)托 .build/stable 的静态件;vite preview 有宿主校验,
经域名 / 反代进来会被拦 —— 放哪些宿主由起它的人说(PREVIEW_ALLOWED_HOSTS),开发那台 vite 不读它。
脚本只列环境变量名,密钥仍只从环境读。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0167qWjeyBwvfdGovd7FWbCu
This commit is contained in:
xcs
2026-08-27 11:44:35 +08:00
co-authored by Claude Fable 5
parent d67f744f59
commit 6b7bf82df3
3 changed files with 393 additions and 0 deletions
+24
View File
@@ -5,7 +5,31 @@ import { fileURLToPath } from 'node:url';
const root = fileURLToPath(new URL('../..', import.meta.url));
const p = (rel: string) => fileURLToPath(new URL(rel, import.meta.url));
/*
* 稳定版(./stable.sh)用 `vite preview` 托 .build/stable 的静态文件。preview 有一道宿主校验
* (防 DNS rebinding),默认只放 localhost 与 IP —— 经域名 / 反代进来会被拦:
* 「Blocked request. This host ("…") is not allowed.」
* 放哪些宿主由起它的人说(PREVIEW_ALLOWED_HOSTS,逗号分隔;`.example.com` 放整个子域;`*` 全放)。
* 开发那台 `vite` 不读这个,不受影响。
*/
const previewHosts = process.env.PREVIEW_ALLOWED_HOSTS?.trim();
const preview =
previewHosts === undefined || previewHosts === ''
? {}
: {
preview: {
allowedHosts:
previewHosts === '*'
? (true as const)
: previewHosts
.split(',')
.map((s) => s.trim())
.filter((s) => s !== ''),
},
};
export default defineConfig({
...preview,
plugins: [react()],
resolve: {
alias: {