[英]Webpack / Angular CLI / Proxy forwarding
我需要在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
謝謝!
你應該改變你的pathRewrite
"/rest/": {
"target": "https://someserver.com/somepath/rest/",
"changeOrigin": true,
"ws": true,
"pathRewrite": {
"^/rest/": "/"
},
"secure": false,
"logLevel": "debug"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.