The main problem is that in one of the http requests the authorization baerer is not inserted...

Discussão em 'Angular' iniciado por Niccolò Boddi, Outubro 8, 2024.

  1. Using an interceptor I add a header with authorization to each http request. All requests are intercepted but when I go to look in the network tab, a request does not have the baerer authorization. The requests are proxied by angular.proxy and I noticed that the request that does not have the authorization has a different behavior than the others. In the network tab the requests are not proxied yet but appear from localhost, while the strange one is already completely proxied. So investigating the forums I thought it could be a CORS problem since the domain changes. In the end I noticed that this was the only http request, and changing it to https I solved it. In the network now I see the authorization and it is not already proxied. It's a bit difficult to explain but I hope I'm clear. The problem is solved but I would like to clarify my ideas on why. Why does the proxy (or network tab) seem to behave differently between http and https?

    I specify that the requests are all proxied correctly even if I don't see them proxied in the network. (I don't know exactly how this works)

    I don't know what part of the code could be useful, I share the proxy.conf before being changed to https.

    {
    "/path/one": {
    "target": "http://one.it",
    "secure": false,
    "changeOrigin": true,
    "logLevel": "debug",
    "pathRewrite": {
    "^/path/one": ""
    }
    },
    "/path/two": {
    "target": "https://two.it",
    "secure":false,
    "changeOrigin": true,
    "logLevel": "debug",
    "pathRewrite": {
    "^/path/two": ""
    }
    }
    }

    Continue reading...

Compartilhe esta Página