CORS PROCEDURES Request successful but freezes in Safari

Safari (10 - OSX El Capitan) Problem with CORS

I am making a CORS POST request from the front-end of AngularJS to the end of Laravel.

  • In Chrome and Firefox, both parameters and the POST request return an http status of 200 OK
  • In Safari 10 (OSX), both the OPTIONS and POST parameters return the http 200 OK status , but the OPTIONS request continues to load (http status 200 OK!)

Request header

Accept:*/* Accept-Encoding:gzip, deflate, sdch Accept-Language:nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4 Access-Control-Request-Headers:content-type Access-Control-Request-Method:POST Cache-Control:no-cache Connection:keep-alive Host:x.local Origin:http://y.local Pragma:no-cache Referer:http://y.local/ 

Answer Header

 Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT Access-Control-Allow-Origin:* Cache-Control:no-cache Connection:keep-alive Content-Length:16 Content-Type:application/json Date:Mon, 31 Oct 2016 09:22:51 GMT Server:nginx/1.11.1 

Safari freezes after receiving http 200 OK status (OPTIONS request). What should I do?

+5
source share
2 answers

Try returning 204 No Content, it worked for me. It is found in some examples without further explanation.

+1
source

Ensure that the Accept header is added to the CORS AllowedHeaders settings. This solved it for me.

Your request has an Accept / header, but your CORS settings do not handle this at all. Modern browsers such as Chrome may work without headers, but Safari is not updated.

+1
source

Source: https://habr.com/ru/post/1259025/


All Articles