feat: configure network access policies through environment

This commit is contained in:
陈煜 committed 2026-10-04 11:27:34 +08:00
1 parent 91365ee315
commit 265f28e16d
17 files changed
+456 -58

No files matched your search

+20 -4
View File
@@ -1,6 +1,22 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: { port: 5173, proxy: { '/api': 'http://127.0.0.1:3100' } },
import { resolve } from 'node:path';
export default defineConfig(({ mode }) => {
const env = { ...loadEnv(mode, resolve(__dirname, '../api'), ''), ...process.env };
const allowed = env.WEB_ALLOWED_HOSTS || '*';
return {
plugins: [react()],
server: {
host: env.WEB_HOST || '0.0.0.0',
port: Number(env.WEB_PORT || 5173),
allowedHosts:
allowed.trim() === '*'
? true
: allowed
.split(',')
.map((v) => v.trim())
.filter(Boolean),
proxy: { '/api': env.WEB_API_PROXY || 'http://127.0.0.1:3100' },
},
};
});