feat: Add proxy to frontend dev server to fix CORS issues

This commit is contained in:
Deroino
2025-11-13 04:11:58 +08:00
parent 756dcd9126
commit e003383d65
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
NODE_ENV=development
# API 基础地址
VITE_API_BASE_URL=http://localhost:5409
VITE_API_BASE_URL=/api
# 应用端口
VITE_PORT=5173
+8 -1
View File
@@ -19,7 +19,14 @@ export default defineConfig({
},
server: {
port: 5173,
open: true
open: true,
proxy: {
'/api': {
target: 'http://localhost:5409',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
},
build: {
outDir: 'dist',