简体   繁体   中英

Response for preflight has invalid HTTP status code 404 - ajax request browser

I have a 404 error with my ajax req (which looks like this) :

 $.ajax({ type:'GET', url:'http://localhost:8000/auth/github', crossDomain:true, headers:{ 'Content-Type':'application/x-www-form-urlencoded', 'Access-Control-Allow-Origin':'*' }, success:function(data){debugger;} }); 

The error looks like this on chrome : see chrome error

And like this one in firefox : see firefox error

I installed cors plugin in my browser, I've tried many changes on the headers, still got the error in my web console.

Also, when I acces my route with postman it all works fine. So I assume the problem come from my browser

Does someone knows how to fix it ?

I saw this topic with the same error but it has no answer yet : Ajax: Response for preflight has invalid HTTP status code 404

Thanks a lot !

I finally figured it out by adding in my headers accept: / . I know this is forbidden in real infra, but mine was just for school so for those who meet the same problem for a school project, just see the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM