28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { defineConfig } from 'vite'
|
||
import react from '@vitejs/plugin-react'
|
||
import tailwindcss from '@tailwindcss/vite'
|
||
|
||
declare const process: { env: Record<string, string | undefined> }
|
||
|
||
// 开发态把 /api 与 /media 代理到本地 FastAPI(默认 127.0.0.1:8000)
|
||
const backend = process.env.NEX_BACKEND || 'http://127.0.0.1:8000'
|
||
|
||
export default defineConfig({
|
||
plugins: [react(), tailwindcss()],
|
||
server: {
|
||
host: '0.0.0.0',
|
||
port: 5173,
|
||
// 局域网访问:IP 默认放行,但 macOS 的 mDNS 机器名(http://xxx.local:5173)会被
|
||
// Vite 的 Host 校验拦成 403「Blocked request」。只放行 .local 后缀,任意域名仍拦住。
|
||
allowedHosts: ['.local'],
|
||
proxy: {
|
||
'/api': { target: backend, changeOrigin: true },
|
||
'/health': { target: backend, changeOrigin: true },
|
||
'/media': { target: backend, changeOrigin: true },
|
||
'/docs': { target: backend, changeOrigin: true },
|
||
'/openapi.json': { target: backend, changeOrigin: true }
|
||
}
|
||
},
|
||
build: { outDir: 'dist', emptyOutDir: true, chunkSizeWarningLimit: 1200 }
|
||
})
|