0

I need to setup a proxy within AngularCLI / Webpack env to forward requests from http://localhost:4200/rest to https://someserver.com/somepath/rest

For one, the endpoint is a https and not a http.

Secondly, the request url could be http://localhost:4200/rest/foo or ...:4200/rest/bar and all and any of the paths coming after '/rest' need to be mapped to https://someserver.com/somepath/rest/foo or ...com/somepath/rest/bar

The following proxy.conf.json doesn't seem to be configured properly:

"/rest": {
    "target": "https://someserver.com",
    "changeOrigin": true,
    "ws": true,
    "pathRewrite": {
      "^/rest/": "/somepath/rest/"
    },
    "secure": false,
    "logLevel": "debug"
  }

The app is started with

ng serve --proxy-config proxy.conf.json --live-reload --host 0.0.0.0

Thanks!

pop
  • 3,464
  • 3
  • 26
  • 43

1 Answers1

1

you should change your pathRewrite

 "/rest/": {
        "target": "https://someserver.com/somepath/rest/",
        "changeOrigin": true,
        "ws": true,
        "pathRewrite": {
          "^/rest/": "/"
        },
        "secure": false,
        "logLevel": "debug"
      }
CharanRoot
  • 6,181
  • 2
  • 27
  • 45