I've looked through all the other questions regarding CORS errors with no luck. I'm making a simple POST request in a NuxtJS client application. If I use axios, I get CORS errors, but if I use fetch, it works just fine. I would like to use axios, but I can't sort this out. The server has the correct "Access-Control-Allow-Origin" headers set (neither option below works when that header is removed). Anyone know why this would work for fetch but not axios?
FAILS
await this.$axios({
url,
method: 'POST',
data
})
WORKS
await fetch(url, {
method: 'POST',
body: JSON.stringify(data)
})
Error message: Access to XMLHttpRequest at {URL} from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
In the network tab of Chrome, the request headers show as follows: