Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response
See original GitHub issueI send POST
request to other server api and get error
XMLHttpRequest cannot load http://example.com/api/v1/auth. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.
After that, I config vue headers like this.
Vue.http.options.xhr = {withCredentials: true}
Vue.http.options.emulateJSON = true
Vue.http.options.emulateHTTP = true
Vue.http.options.crossOrigin = true
Vue.http.headers.common['Access-Control-Allow-Origin'] = '*'
Vue.http.headers.common['Content-Type'] = 'application/x-www-form-urlencoded'
Vue.http.headers.common['Accept'] = 'application/json, text/plain, */*'
Vue.http.headers.common['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, Authorization, Access-Control-Allow-Origin'
but, that error has occurred. Can you give me correct config Vue-resouce to fix this problem.
Thanks so much.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Request header field Access-Control-Allow-Headers is not ...
When you start playing around with custom request headers you will get a CORS preflight. This is a request that uses the HTTP...
Read more >Access-Control-Allow-Headers - HTTP - MDN Web Docs
The Access-Control-Allow-Headers response header is used in response to a preflight request which includes the ...
Read more >Request header field content-type is not allowed by Access ...
My netlify function has these headers set up: const headers = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': ...
Read more >CORS error: Request header field Authorization is not allowed ...
The CORS error "Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response" occurs when your browser ...
Read more >'Request header field authorization is not allowed by Access ...
'Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.' in a POST Request #2345.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried this inside js/bootsrap.js
window.axios.defaults.headers.common = { ‘Accept’: ‘application/json’, ‘Content-Type’: ‘application/json’ };
That worked for me after spending more than 4 hours battling with same error. I’m on Laravel, Vuejs 2.4.2 and using Axios
@steffans Sorry, I’m using postman for send request to api. It still work. I don’t think problem lies in server?