feat: 添加vite的proxy代理设置

This commit is contained in:
2026-06-09 10:15:22 +08:00
parent ed86444fe6
commit 44b0de35df
2 changed files with 12 additions and 1 deletions

View File

@@ -28,5 +28,16 @@ export default defineConfig({
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
'/api': {
/** 后端服务地址,按需修改 */
target: 'http://localhost:8080',
changeOrigin: true,
/** 去掉 /api 前缀转发给后端(如 /api/auth/login → /auth/login */
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
})