1.ios12 系统跨域请求,状态码0

2.原因:跨域请求options中请求头缺少参数
请求头信息 Access-Control-Request-Headers: accept, content-type, origin
3.nginx反向代理的解决方法:判断是optinos,添加参数Origin,Accept

if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Headers 'Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,Origin,Accept,X-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,tenant';
add_header Access-Control-Allow-Credentials 'true';
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
return 204;
}
本文针对iOS 12系统下跨域请求出现的状态码0问题进行了详细解析,并给出了通过修改nginx配置文件来解决该问题的具体步骤。文章重点介绍了如何在options请求中正确设置请求头,以确保跨域请求能够正常工作。

2877

被折叠的 条评论
为什么被折叠?



