返回顶部

umi——设置proxy代理后,请求status一直为500

参考:umi.js proxy设置https请求不验证证书-- 解决SELF_SIGNED_CERT_IN_CHAIN https://blog.csdn.net/u010974701/article/details/86940422

 

我的情况

umi项目,设置proxy代理后,请求status一直为500

.umirc.ts:

proxy: {
    '/api': {
      target: 'https://xxx', // 服务端域名
      changeOrigin: true, // 允许域名进行转换
      pathRewrite: { '^/api': '' }, // 将请求url里的ci去掉
    },
  },

终端报错:

[HPM] Error occurred while proxying request localhost:8000/xxx/loginxxx to https://xxx/ [DEPTH_ZERO_SELF_SIGNED_CERT] (https://nodejs.org/api/errors.html#errors_common_system_errors)

 

原因

https请求校验了证书

 

解决方法

代理时不校验证书

 proxy: {
    '/api': {
      target: 'https://xxx', // 服务端域名
      changeOrigin: true, // 允许域名进行转换
      pathRewrite: { '^/api': '' }, // 将请求url里的ci去掉
      secure: false, // 《= 关键  代理https请求时,不进行证书验证
    },
  },

 

posted @ 2024-07-31 16:12  前端-xyq  阅读(10)  评论(0编辑  收藏  举报