0

我需要设置AngularCLI/ENV的WebPack内的代理从http://localhost:4200/rest请求转发到https://someserver.com/somepath/rest的WebPack /角CLI /代理转发

其一,终端是HTTPS而不是HTTP。

其次,请求URL可以是http://localhost:4200/rest/foo...:4200/rest/bar,所有和任何后“/休息”未来的路径需要被映射到https://someserver.com/somepath/rest/foo...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 

谢谢!

回答

1

你应该改变你的pathRewrite

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

这工作。谢谢。 – pop