javascript - CORS OPTIONS Request Successful, but Hangs in Safari - Stack Overflow

Safari (10 - OSX El Capitan) Issue with CORSI'm doing a CORS POST request from AngularJS front-end

Safari (10 - OSX El Capitan) Issue with CORS

I'm doing a CORS POST request from AngularJS front-end to Laravel Back-end.

  • In Chrome and Firefox, both OPTIONS and POST request return http status 200 OK
  • In Safari 10 (OSX), both OPTIONS and POST request return http status 200 OK, but the OPTIONS request keeps loading (http status 200 OK!)

Request Headers

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:
Pragma:no-cache
Referer:/

Response Headers

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 hangs, after I get the http status 200 OK (OPTIONS request). What should I do?

Safari (10 - OSX El Capitan) Issue with CORS

I'm doing a CORS POST request from AngularJS front-end to Laravel Back-end.

  • In Chrome and Firefox, both OPTIONS and POST request return http status 200 OK
  • In Safari 10 (OSX), both OPTIONS and POST request return http status 200 OK, but the OPTIONS request keeps loading (http status 200 OK!)

Request Headers

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/

Response Headers

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 hangs, after I get the http status 200 OK (OPTIONS request). What should I do?

Share edited Jul 10, 2017 at 16:47 mortalis 2,15125 silver badges37 bronze badges asked Oct 31, 2016 at 9:29 schellingerhtschellingerht 5,8062 gold badges30 silver badges56 bronze badges 4
  • 2 Sounds similar to stackoverflow./questions/38789251/… (no answer) – Günter Zöchbauer Commented Oct 31, 2016 at 9:31
  • 2 This also looks similar groups.google./forum/#!topic/angular/3hP4JpTHLYY – Günter Zöchbauer Commented Oct 31, 2016 at 9:37
  • @GünterZöchbauer Thanks, but it doesn't work for me both HTTP and HTTPS. – schellingerht Commented Oct 31, 2016 at 9:48
  • Didn't look like it contains a clear solution, but it looked like some things worth trying. – Günter Zöchbauer Commented Oct 31, 2016 at 9:53
Add a ment  | 

2 Answers 2

Reset to default 2

Try returning 204 No Content, that worked for me. It is found in some examples with no further explanations.

Make sure you have the Accept header added to your CORS AllowedHeaders options. This solved it for me.

Your request has an Accept header of /, but your CORS options doesn't handle that at all. Modern browsers like Chrome can work without the headers, but Safari has not stayed up to date.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744862621a4597792.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信