Axios: getting two requests OPTIONS & POST

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:

  1. You can set Access-Control-Allow-Origin: * on your server to disable CORS.

  2. Make your CORS request a simple one. You will have to change the Content-Type header to application/x-www-form-urlencoded, multipart/form-data, or text/plain. Not application/json.

I’d say just leave it as it is if the OPTIONS request is not blocking you.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)