CORS GET returns an empty response body in Firefox

后端 未结 2 2107
春和景丽
春和景丽 2021-01-04 03:28

From a RESTful Backbone application, I\'m doing CORS requests from mydomain.com to myExtdomain.com.

I did set up CORS on my

相关标签:
2条回答
  • 2021-01-04 03:45

    For me, the solution was to add Access-Control-Allow-Credentials: true in response headers of server side: this is the symmetric of setting request.withCredentials = true; for a XMLHttpRequest object on client side.

    0 讨论(0)
  • 2021-01-04 03:49

    Adding the Cache-Control: no-cache header to all my API calls Responses (on myExtdomain.com) solved my problem:

    Access-Control-Allow-Origin: *
    Content-Type: application/json
    Cache-Control: no-cache
    

    For some reason, Firefox was caching my API calls, and when cached, FF was not able to parse the JSON again.. Ending up in an empty response body or whatever error that was..

    Now I remember this is not the first time I have to force no-cache with Firefox..

    Again, everything was working fine with Chrome, Chrome does not need the Cache-Control: no-cache header.

    If someone know about this difference between FF and Chrome (default settings??), I'd be curious to no more about it.

    Hope this will save some time to somebody.

    0 讨论(0)
提交回复
热议问题