question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default headers for authorization not working on 0.19.0

See original GitHub issue

I’m using several axios instances to send requests to different endpoints but I’m setting an access token authorization header in axios defaults like this:

axios.defaults.headers['Authorization'] = 'Bearer ' + myToken

In version 0.18.1 everything works fine and the token is sent on every request. After update to version 0.19.0 it stopped working.

I read in the documentation that I should set default headers like this: axios.defaults.headers.common['Authorization'] = 'Bearer ' + myToken, but it doesn’t work. No authorization header is sent.

I even throw a console.log(axios.defaults.headers.common['Authorization']) before one of my requests and the token is there in axios defaults, but it seems to ignore it.

Couldn’t find anything in documentation telling if something changed from the previous version. So either it’s a bug or I’m doing something wrong. I would like you to clarify me.

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:12

github_iconTop GitHub Comments

3reactions
yasufcommented, Oct 18, 2019

hmm weird, a few more people are reporting bugs with 0.19, most likely this will need investigation, thanks for the heads up

2reactions
maxpareliuscommented, Nov 13, 2019

Seeing issues as well. When trying to add Authorization header to axios Get request it appears the header never actually gets attached. Had to switch back to the fetch api for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default Authorization header no longer working in 0.19.0 #2199
Since axios 0.19.0, the default Authorization header is no longer set in query. It works in 0.18.X. To Reproduce Create an axios adapter...
Read more >
Unable to add Axios Default Headers to VueJS app
Set defaults to an instance and use it to make requests. const adapter = axios.create({ baseURL: 'http://localhost:8080/my-api', headers: { ...
Read more >
WWW-Authenticate - HTTP - MDN Web Docs
This new request uses the Authorization header to supply the credentials ... Valid non-session values are: "MD5" (default if not specified), ...
Read more >
cookie header axios | The AI Search Engine You Control
From the documentation of axios you can see there is a mechanism available which allows you to set default header which will be...
Read more >
Auth token is not passing through header - the Tyk community
My APIs are already using Bearer tokens for their authentication. When I am using the Auth token from the portal then it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found