Cloudflare 524 error with AJAX

我是研究僧i 提交于 2021-01-27 02:45:55

问题


I'm making an ajax request to a site behind Cloudflare. After 100 seconds, I get a 524. However I'm unable to process that 524 in my Javascript as the error page is served directly by Cloudflare and does not contain the required Access-Control-Allow-Origin headers.

I wish to retry the query in the event of getting a 524.


回答1:


If you know that CloudFlare edge will wait for a HTTP response from the server for exactly 100 seconds, then you could just setup a timeout equal to 100 seconds on the ajax request. And retry the query after the timeout.

Alternatively, you can move this request into subdomain which is not under cloud flare proxy.


Another idea is to use a reverse proxy and adding CORS headers. In the Apache that would be

<LocationMatch "/ajax-request-used-in-js">
   ProxyPass http://example.com/ajax
   Header add "Access-Control-Allow-Origin" "*"
</LocationMatch>


来源:https://stackoverflow.com/questions/37381923/cloudflare-524-error-with-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!