25 lines
716 B
TypeScript
25 lines
716 B
TypeScript
import { fileURLToPath, URL } from 'node:url';
|
||
import { defineConfig } from 'vite';
|
||
import react from '@vitejs/plugin-react-swc';
|
||
|
||
// 前端开发服务器,/api 代理到本地 FastAPI(server/)
|
||
export default defineConfig({
|
||
plugins: [react()],
|
||
resolve: {
|
||
alias: {
|
||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||
},
|
||
},
|
||
server: {
|
||
port: 8900,
|
||
strictPort: true, // 端口被占用时直接报错,而不是自动改到别的端口
|
||
open: true, // 启动后自动打开浏览器
|
||
proxy: {
|
||
'/api': {
|
||
target: 'http://127.0.0.1:8800',
|
||
changeOrigin: true,
|
||
},
|
||
},
|
||
},
|
||
});
|