开启跨域请求后无效

ziying 2019-8-16 495

昨天升级到最新版的ngix和拍黄片,设置允许跨域后,无法生效

发送ajax请求时报如下错误

Access to XMLHttpRequest at 'https://api.phpjishu.com' from origin 'https://cbb.phpjishu.com' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

该域名为测试域名,可以进行尝试

最新回复 (3)
  • 虚竹 2019-8-16
    引用 2
    实测正常。
  • ziying 2019-8-16
    引用 3
    因为我手动修改了配置临时用的,自动生成的配置是错误的
  • ziying 2019-8-16
    引用 4



    改成关闭跨域,然后在配置文件里新增了这三行
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

返回
发新帖