peng
2025-11-07 f64693c0da5483d8670220bf3a5bf89a32e94a20
web/vite.config.ts
@@ -15,22 +15,11 @@
    open: true,
    proxy: {
      '/api': {
        // 将API代理回本地后端,便于完整联调(后端运行在 http://127.0.0.1:8080/api)
        target: 'http://127.0.0.1:8080',
        changeOrigin: true,
        secure: false,
        configure: (proxy, options) => {
          proxy.on('error', (err, req, res) => {
            console.log('proxy error', err);
          });
          proxy.on('proxyReq', (proxyReq, req, res) => {
            console.log('Sending Request to the Target:', req.method, req.url);
          });
          proxy.on('proxyRes', (proxyRes, req, res) => {
            console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
          });
        },
        // 不需要重写路径,因为后端的context-path就是/api
        // rewrite: (path) => path.replace(/^\/api/, '/api')
        // 不需要重写路径,因为后端的context-path就是 /api
      }
    }
  },