diff --git a/vite.config.ts b/vite.config.ts index 2fae3c8..0889fbb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,5 +35,12 @@ export default defineConfig({ }, server: { host: true, + proxy: { + '/api': { + target: 'http://localhost:7777', // 测试服务器地址,可根据实际后端地址修改 + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ''), // 如果后端接口本身没有 /api 前缀,需要将其重写掉 + }, + }, }, })