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