duke
duke

Reputation: 135

how to config proxy.config.json for angular

I use a proxy.config.json for the http-calls.

my example:

 "/api/countries/*": {
    "target": "http://localhost:8084/countries",
    "secure": false,
    "changeOrigin": true,
    "pathRewrite": {
      "^/api/countries": ""
    },
    "logLevel": "debug"
  }
}

I have to call http://localhost:8084/countries. (works fine) and http://localhost:8084/countries/textParam

The latter is not proxied. it is rewritten to just: /textParam

[HPM] Rewriting path from "/api/countries/textParam" to "/textParam"

And the http.put-request looses the textParam.

[HPM] PUT /api/countries/textParam ~> http://localhost:8084/countries

I could not find a doc that helped me.

how do I have to enhance my config?

thanx for helping.

Upvotes: 1

Views: 9056

Answers (1)

Savan2396
Savan2396

Reputation: 122

You have to try , "target":"http://localhost:8084"

and try /api/* instead of /api/countries/* .

please refer this link https://github.com/angular/angular-cli/wiki/stories-proxy

Upvotes: 2

Related Questions