gpt4 book ai didi

由于 Access-Control-Allow-Origin,AngularJS $http 调用失败

转载 作者:行者123 更新时间:2023-12-05 08:08:43 26 4
gpt4 key购买 nike

我在 $http 调用中使用 withCredentials: true 来在请求 header 中发送 session ID。

但我正面临:

"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'. Origin 'null' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."

所以我将服务器端的 CORS 过滤器更改为:

response.setHeader("Access-Control-Allow-Origin", "http://localhost:8080/");

现在我收到这个错误:

"The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8080' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access."

谁能告诉我解决方案?

最佳答案

尝试使用这个片段:

response.setHeader("Access-Control-Allow-Origin", "*");

关于由于 Access-Control-Allow-Origin,AngularJS $http 调用失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46140657/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com