0

我需要在 AngularCLI / Webpack env 中设置一个代理来将请求转发http://localhost:4200/resthttps://someserver.com/somepath/rest

一方面,端点是 https 而不是 http。

其次,请求 url 可以是http://localhost:4200/rest/fooor...:4200/rest/bar并且所有和任何在 '/rest' 之后的路径都需要映射到https://someserver.com/somepath/rest/fooor...com/somepath/rest/bar

以下 proxy.conf.json 似乎没有正确配置:

"/rest": {
    "target": "https://someserver.com",
    "changeOrigin": true,
    "ws": true,
    "pathRewrite": {
      "^/rest/": "/somepath/rest/"
    },
    "secure": false,
    "logLevel": "debug"
  }

该应用程序开始于

ng serve --proxy-config proxy.conf.json --live-reload --host 0.0.0.0

谢谢!

4

1 回答 1

1

你应该改变你的pathRewrite

 "/rest/": {
        "target": "https://someserver.com/somepath/rest/",
        "changeOrigin": true,
        "ws": true,
        "pathRewrite": {
          "^/rest/": "/"
        },
        "secure": false,
        "logLevel": "debug"
      }
于 2017-06-20T14:56:00.677 回答