0๐
โ
We get a CORS Policy Error because we have these default headers in our bootstrap.js
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
You should remove default headers for one request in axios. You can use the transformRequest
in the request you are making:
axios.get('xxxx.com', { transformRequest: [(data, headers) => {
delete headers.common['X-Requested-With'];
return data
}] })
.then((response) => {
console.log(response);
})
Source:stackexchange.com