AJAX的Cloudflare 524错误 [英] Cloudflare 524 error with AJAX

查看:71
本文介绍了AJAX的Cloudflare 524错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向Cloudflare后面的站点发出ajax请求.100秒后,我得到了524.但是我无法在Javascript中处理该524,因为错误页面是由Cloudflare直接提供的,并且不包含必需的Access-Control-Allow-Origin标头.

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.

在获取524的情况下,我希望重试该查询.

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

推荐答案

如果您知道CloudFlare edge将等待服务器的HTTP响应恰好100秒,那么您可以在服务器上设置等于100秒的超时ajax请求.并在超时后重试查询.

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.

另一个想法是使用反向代理并添加CORS标头.在Apache中应该是

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>

这篇关于AJAX的Cloudflare 524错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆