web/vite.config.ts
@@ -10,13 +10,16 @@ } }, server: { host: '0.0.0.0', port: 3000, open: true, proxy: { '/api': { target: 'http://localhost:8080', // 将API代理回本地后端,便于完整联调(后端运行在 http://127.0.0.1:8080/api) target: 'http://127.0.0.1:8080', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '/api') secure: false, // 不需要重写路径,因为后端的context-path就是 /api } } },