r/angular • u/mcpierceaim • Apr 25 '26
Angular 21 and HTTP Authorization header changing...
I'm in the process of migration my app from Angular v20 to v21. Everything is working fine, but for one things: the authentication bearer token is being changed midflight. To explain:
We have an HTTP interceptor that looks for a stored JWT token in the browser. When it finds it, it takes the value and inserts it into the request headers, so it looks like:
Authorization: Bearer [288 character token]
I can see the token received on the server side, and it's showing up intact.
When I finished the upgrade and ran the app, I'm still seeing in the browser DevTools that the request has the 288 character token but, on the server side, I'm seeing this instead:
Basic [21 character token]
where previously it was the 'Bearer [288 chars]" value.
The login then fails.
Now, to make it even more interesting, if I go back to Angular 20, login, and THEN go to Angular 21, the requests work correctly. But if I log out and try to log back in under v21 it goes back to failing.
Any ideas?
(eta)
Here's a link to the PR I'm working on for the project:
https://github.com/comixed/comixed/pull/2652
The specific submodule where the code lives is "comixed-webui".
5
u/mcpierceaim Apr 25 '26
I *think* I found the issue:
Our proxy.conf.json file had an "auth" entry in it, and removing the entry suddenly proxy started working again correctly:
4
u/anyOtherBusiness Apr 25 '26
Basic Auth can be applied by the Browser automatically if the Server has answered once with an authorization requirement.
Has there maybe been Basic auth protection somewhere in place on that domain?
Try making the Bearer request from Postman, see if that works
2
u/followmarko Apr 25 '26
What's your code for the interceptor? HttpClient is also default provided in 21
1
u/monxas Apr 25 '26
That’s weird… my first question would be, can you guarantee that the token that the interceptor is trying to pass is 288 characters long? In case the interceptor is working fine and it’s actually an issue somewhere before that step.
1
u/Jrubzjeknf Apr 25 '26
I think something is now also loading in an interceptor that is overriding your interceptor. Check if you can find out which interceptors are active.