问题:
今天做项目有个服务器遇到一个问题,
1)ajax无法发送同步请问,改为true后就可以了, firefox浏览器没有问题,chrome有问题
2)相同的core,其他服务器没有问题,就这个服务器遇到了这样的问题
检查:
查看页面的header,debug->网络->输入url,e.g:login.admin。查看header里面的请求参数
对比chrome里面不同服务器的header.发现header里面的请求参数不一样
3)在nginx.conf里面找到相应的参数,对比得出:
有问题的服务器设置了:
add_header Feature-Policy sync-xhr 'none';
就是这个设置,拦截了同步请求,修改为sync-xhr 'self';
就OK了
补充:
the sync-xhr setting:
'*': It is allowed in both pages and embedded iframes.
'self': Allowed on the page, only the same source resources are allowed to be used in the embedded iframes.
'src': Only the attributes that are valid in the iframe, only the src attribute in the iframe is allowed to use the same resource as the set header.
'none': All prohibited in pages and inline.
<origin(s)>: Allowed to be used in a specific origin, multiple origins can be separated by spaces.
'*' and 'none' are used alone, 'self' and 'src' can be used side by side with one or more origins.