From 74e75ec7a58119558ee426a40e072f1b9866be89 Mon Sep 17 00:00:00 2001 From: jingrow Date: Tue, 4 Nov 2025 00:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96vite=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0VITE=5FALLOWED=5FHOSTS=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jingrow/frontend/vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/jingrow/frontend/vite.config.ts b/apps/jingrow/frontend/vite.config.ts index d268e90..3d78078 100644 --- a/apps/jingrow/frontend/vite.config.ts +++ b/apps/jingrow/frontend/vite.config.ts @@ -33,6 +33,7 @@ export default defineConfig(({ mode }) => { const BACKEND_URL = env.VITE_BACKEND_SERVER_URL const FRONTEND_HOST = env.VITE_FRONTEND_HOST || '0.0.0.0' const FRONTEND_PORT = Number(env.VITE_FRONTEND_PORT) || 3100 + const ALLOWED_HOSTS = (env.VITE_ALLOWED_HOSTS || '').split(',').map((s) => s.trim()).filter(Boolean) return { plugins: [ @@ -63,6 +64,8 @@ export default defineConfig(({ mode }) => { strictPort: true, open: false, cors: true, + // 允许通过指定域名访问开发服务器(可通过 VITE_ALLOWED_HOSTS 配置,逗号分隔) + ...(ALLOWED_HOSTS.length ? { allowedHosts: ALLOWED_HOSTS } : {}), fs: { // 放行 monorepo apps 目录,便于 import.meta.glob 跨应用扫描 allow: [appsDir]