proxy.conf.js 727 B

12345678910111213141516171819202122
  1. const PROXY_CONFIG = {
  2. "/api": {
  3. target: "http://localhost:3002",
  4. secure: false,
  5. changeOrigin: true,
  6. logLevel: "debug",
  7. onProxyReq: (proxyReq, req, res) => {
  8. // 确保转发 Authorization header
  9. if (req.headers.authorization) {
  10. proxyReq.setHeader('Authorization', req.headers.authorization);
  11. console.log('[Proxy] 转发 Authorization header:', req.headers.authorization.substring(0, 30) + '...');
  12. } else {
  13. console.log('[Proxy] 请求没有 Authorization header');
  14. }
  15. },
  16. onProxyRes: (proxyRes, req, res) => {
  17. console.log('[Proxy] 响应状态:', proxyRes.statusCode, '请求:', req.method, req.url);
  18. }
  19. }
  20. };
  21. module.exports = PROXY_CONFIG;