【问题标题】:Angular Proxy HTTPsAngular 代理 HTTPs
【发布时间】:2021-06-12 20:04:30
【问题描述】:

我需要将来自 localhost 的请求代理到 HTTPS 后端。我使用文档中的这段代码:

{
  "/api": {
    "target":  "https://my-domain",
    "secure": false,
    "logLevel": "debug",
    "pathRewrite": {
      "^/api": "/env/api"
    }
  }
}

但是它返回一个错误:

[HPM] 尝试将请求 /env/api/my/url/ 从 localhost:4200 代理到 https://my-domain (EPROTO) (https://nodejs.org/api/errors.html#errors_common_system_errors) 时出错

【问题讨论】:

    标签: angular proxy


    【解决方案1】:

    使用此配置修复:

    {
      "/api": {
        "target":  "https://my-domain",
        "secure": false,
        "logLevel": "debug",
        "pathRewrite": {
          "^/api": "/env/api"
        }
      },
      "changeOrigin": true
    }
    

    【讨论】:

      猜你喜欢
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 2018-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-03
      • 2011-12-09
      相关资源
      最近更新 更多