Axios is sending the Authorization header in preflight requests
See original GitHub issueSummary
Axios is sending the Authorization header in preflight requests, which it shouldn’t
There should be an option to enable/disable this
The error is
Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
This doesn’t work (the jquery ajax alternative works)
HTTP.get("http://mysite.com/",{
responseType: 'text',
withCredentials: true,
auth: {
username: "abcd",
password: "1234"
}
})
.then(response => {});
This works (after entering the username and password in the pop up)
HTTP.get("http://mysite.com/",{
responseType: 'text',
withCredentials: true,
/*auth: {
username: "abcd",
password: "1234"
}*/
})
.then(response => {});
Context
- axios version: 0.18.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
How to send authorization header with axios - Stack Overflow
I have tried a few things without success, for example: const header = `Authorization: Bearer ${token}`; return axios. get(URLConstants. USER_ ...
Read more >Using Axios to set request headers - LogRocket Blog
Learn different ways Axios can be used to set request headers for API calls. ... This code sets authorization headers for all requests:...
Read more >How to send the authorization header using Axios
To set headers in an Axios POST request, pass a third object to the axios.post() call. You might already be using the second...
Read more >axios has been blocked by cors policy: response to preflight ...
Solution 1: Access-Control-Allow-Origin is a response header - so in order to enable CORS - We need to add this header to the...
Read more >Preflight request - MDN Web Docs Glossary: Definitions of ...
A CORS preflight request is a CORS request that checks to see if the CORS protocol is understood and a server is aware...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
CORS problem, instead of an axios issues.
I decide this issue with setting server’s answer
$response->headers->add('Access-Control-Allow-Headers', 'Authorization, Content-Type');