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!

1 Answer 1

1

you should change your pathRewrite

 "/rest/": {
        "target": "https://someserver.com/somepath/rest/",
        "changeOrigin": true,
        "ws": true,
        "pathRewrite": {
          "^/rest/": "/"
        },
        "secure": false,
        "logLevel": "debug"
      }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.