我需要在AngularCLI / Webpack环境中设置一个代理,以便将请求从http://localhost:4200/rest转发到https://someserver.com/somepath/rest
首先,端点是https而不是http。
其次,请求url可以是http://localhost:4200/rest/foo或...:4200/rest/bar,'/rest‘后面的所有路径都需要映射到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谢谢!
发布于 2017-06-20 22:56:01
您应该更改您的pathRewrite
"/rest/": {
"target": "https://someserver.com/somepath/rest/",
"changeOrigin": true,
"ws": true,
"pathRewrite": {
"^/rest/": "/"
},
"secure": false,
"logLevel": "debug"
}https://stackoverflow.com/questions/44653599
复制相似问题