CORS GET returns an empty response body in Firefox

后端 未结 2 2110
春和景丽
春和景丽 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: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.

提交回复
热议问题