Non-simple CORS requests via AJAX are pre-flighted. Read more about it here. This is a browser behavior and nothing specific to axios. There’s nothing inherently wrong with this behavior and if it’s working for you, you can just leave it.
If you insist on getting rid of it, there are a few ways you can go about:
-
You can set
Access-Control-Allow-Origin: *on your server to disable CORS. -
Make your CORS request a simple one. You will have to change the
Content-Typeheader toapplication/x-www-form-urlencoded,multipart/form-data, ortext/plain. Notapplication/json.
I’d say just leave it as it is if the OPTIONS request is not blocking you.