美文网首页
2019-04-14

2019-04-14

作者: 大唐帝国 | 来源:发表于2019-04-14 21:20 被阅读0次

from origin 'http://localhost:8000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

非跨域问题,解决方法 withCredentials: false

如果一定要设置为true则服务端设置

    header("Access-Control-Allow-Origin: http://localhost:8000");
或者  php      header("Access-Control-Allow-Origin: ".$_SERVER['HTTP_ORIGIN']);

        header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, X-Access-Token');
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Allow-Methods: GET, POST, HEAD, PUT, DELETE, PATCH, OPTIONS');

相关文章

网友评论

      本文标题:2019-04-14

      本文链接:https://www.haomeiwen.com/subject/xacewqtx.html