webpack devserver代理到https,给出“尝试代理请求时发生错误”和SELF_SIGNED_CERT_IN_CHAIN

xa9qqrwz  于 2023-01-13  发布在  Webpack
关注(0)|答案(2)|浏览(365)

尝试设置从localhost到https站点的代理时,出现以下错误

[HPM] Error occurred while trying to proxy request /api/analytics/getDataByPage from localhost:8080 to https://example.com:19502 (SELF_SIGNED_CERT_IN_CHAIN) (https://nodejs.org/api/errors.html#errors_common_system_errors)
5f0d552i

5f0d552i1#

设置secure: false修复了该问题:

proxy: [
  {
    context: ["/api/**"],
    secure: false, // had an expression which was resolving to true
    changeOrigin: true,
  }
]
uqdfh47h

uqdfh47h2#

我也遇到过同样的问题,我的API没有运行,因为我使用的是太新版本的Node(18.),改用16. 解决了这个问题。

相关问题