HTTP request headers not being forwarded by Angular proxy

Viewed 58

I've set up proxy.conf.json to reroute requests from the development server on localhost to my API (which is already running in production). This is what I have:

{
  "/api/*": {
    "target": API_URL,
    "secure": true,
    "changeOrigin": true,
    "pathRewrite": {
      "^/api": "/api/v1"
    },
    "logLevel": "debug"
  }
}

For example, localhost:4200/api/get_token should be rerouted to API_URL/api/v1/get_token. The requests are rerouted correctly, but the headers aren't being forwarded. This is what the log says:

[HPM] Rewriting path from "/api/get_api_token" to "/api/v1/get_api_token"
[HPM] POST /api/get_api_token ~> API_URL

Request headers from DevTools

What should I do to solve this?

0 Answers
Related