您的位置:首页 > 汽车 > 时评 > 杭州公司查询_上海企业网站seo多少钱_专门的网页制作工具有_seo关键词排名网络公司

杭州公司查询_上海企业网站seo多少钱_专门的网页制作工具有_seo关键词排名网络公司

2025/8/13 21:15:03 来源:https://blog.csdn.net/2301_76648183/article/details/145502736  浏览:    关键词:杭州公司查询_上海企业网站seo多少钱_专门的网页制作工具有_seo关键词排名网络公司
杭州公司查询_上海企业网站seo多少钱_专门的网页制作工具有_seo关键词排名网络公司

1、问题

        localhost/:1 Access to XMLHttpRequest at 'xxx'(请求) from origin 'http://localhost:xxx'(本地) has been blocked by CORS policy: 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

并且请求已经发送成功(net::ERR_FAILED 200 (OK))

2、解决方法(仅针对axios和使用axios封装)

在请求的时候,如果不需要发送凭据(如 cookies 或 HTTP 认证信息),可以在请求中禁用 withCredentials

即在请求的时候,如果是get请求,在第二个参数的位置添加 { withCredentials: false // 禁用凭据
}

        axios.get('xxx', { withCredentials: false // 禁用凭据})
                .then(res=> console.log(res.data))
                .catch(error => console.error('Error:', error));

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com