尝试执行fetch请求时出现问题。
fetch("https://localhost:5001/api/Blog/", {
method: "GET",
mode: "no-cors",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
credentials: "include"
}).then(response => {
console.log(response);
return response.json();
}).then(data => {
console.log(data);
}).catch(err => {
console.log(err);
});这是我发送的请求,这是我收到的错误。
GET https://localhost:5001/api/Blog/ net::ERR_CERT_AUTHORITY_INVALID
有人知道我如何避免这个错误吗?注意:我已经在另外两台计算机上测试了该请求,并且运行良好。
发布于 2021-03-06 03:33:36
通过将我的GET请求更改为mode: "cors",并在受信任的根机构中信任我的API。我能够向API发送请求。不知道为什么会这样,但这是我的解决方案。
发布于 2021-03-06 02:34:11
将https://localhost:5001/api/Blog/替换为http://localhost:5001/api/Blog/。
您不应该使用https进行开发。
https://stackoverflow.com/questions/66497812
复制相似问题