qlabfgerkaSmurf
qlabfgerkaSmurf

Reputation: 396

Angular proxy config with basic authorization

I have a proxy for my API that requires basic authorization (username:password). This is what I have tried so far in my proxy config, but what am I missing?

{
    "/api/*": {
        "target": "https://example.com",
        "secure": false,
        "logLevel": "debug",
        "changeOrigin": true,
        "headers": {"Authorization": "Basic ..."}
    }
}

I have also tried adding this:

"auth": "username:password",

If i remove the basic auth on my backend, it works like it should, but i would like to have authorization.

Upvotes: 1

Views: 4565

Answers (1)

vorant
vorant

Reputation: 708

I took the answer from here https://vividcode.io/use-proxy-in-angular-cli/

In nutshell

{
    "/api/*": {
        "target": "https://example.com",
        "secure": true,
        "logLevel": "debug",
        "changeOrigin": true,
        "auth": "username:password"
    }
}

Upvotes: 1

Related Questions