Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance defaults example in README #2112

Closed
esimons opened this issue Apr 25, 2019 · 3 comments
Closed

Instance defaults example in README #2112

esimons opened this issue Apr 25, 2019 · 3 comments

Comments

@esimons
Copy link

esimons commented Apr 25, 2019

Section/Content To Improve
https://github.com/axios/axios/blob/master/README.md#custom-instance-defaults

Suggested Improvement
Remove example code which is known to be problematic in the version of Axios which is currently tagged as latest (0.18.0):

- // Alter defaults after instance has been created
- instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;

Relates to #1395
It would be great to replace this block with a note on how to safely set default headers on a created instance of Axios without inadvertently modifying global defaults, but at a minimum the docs shouldn't be directing users towards trouble with its code examples.

Relevant File(s):
README.md

@LazaroOnline
Copy link

I'm also suffering this exact issue, in my case adding security Auth token to the headers is adding that to all the instances. Resulting in a security risk if I didn't notice, and making the other instances fail and send tokens where they are not supposed to be sent.
Please fix this and the related issue!

@freakymittal
Copy link

I couldn't find a way to do thing without modifying the globals. Either we can add a transform request intercepter there or there has to be another function provided in the axios instance which can do the same.

@chinesedfan
Copy link
Collaborator

Closed by #3539.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants