-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Custom header not being sent during OPTIONS request. #3464
Comments
I am having the same problem. Im about to try it using something like this:
Ill let you know if it works... |
I have the same problem, any solutions? |
No, any solution yet? |
Unfortunately this isn't something axios can fix —at least not in this case. In browser environments, CORS-preflight requests are initiated and entirely managed by the user agent; the preflight operations are completely opaque to our userland code and axios has no ability to add additional headers to the outgoing If you're fortunate enough to control the backend (APIGee server at server.abc.com in this case), the solution is to update the server code to correctly handle CORS-preflight requests; I recommend this great explainer from MDN as a starting point. |
Solution: if you got access to the backend (you're using AWS API Gateway for example), you can disable authorization for OPTIONS requests. I am no security expert and don't know if that creates possible risks, but this suggestion came from AWS support center itself so take that however you will. According to Stackoverflow there is no way to send custom headers during preflight in browsers:
But in the very next sentence the author gives the impression that there is a way to make it work even in browsers by using The confusing (and stupid) thing here is, that this only applies to the browser. Postman or Axios from the terminal are apparently not affected. |
Describe the issue
Axios not sending custom header during OPTIONS request.
I use axios
0.18.0
in my Vue.js application that is running in e.g. cms.abc.com. and the server is running on APIGee with url server.abc.com.When I check the logs from APIGee I'm not receiving the value of
x-api-key
on OPTIONS request.Example Code
Expected behavior, if applicable
I'm expecting that axios is also sending the
x-api-key
during OPTIONS request. It only sends during GET request. Not sure if browsers really not sending custom headers during pre-flight request.Environment
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: