簡體   English   中英

Webpack / Angular CLI /代理轉發

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM