【发布时间】:2017-06-20 12:52:09
【问题描述】:
我需要在 AngularCLI / Webpack env 中设置一个代理来将来自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
谢谢!
【问题讨论】:
标签: node.js angular angular-cli webpack-dev-server http-proxy-middleware