net::ERR_CERT_AUTHORITY_INVALID 在新的 Microsoft Edge 上使用 JavaScript 获取请求

发布时间:2021-03-05 18:32

尝试执行提取请求时出现问题。

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

任何人都知道我如何解决这个错误。 笔记: 我已经在另外 2 台计算机上测试了该请求,效果很好。

回答1

https://localhost:5001/api/Blog/ 替换为 http://localhost:5001/api/Blog/

您不应该使用 https 进行开发。

回答2

通过将我的 GET 请求更改为 mode: "cors" 并在受信任的根权限中信任我的 API。我能够向 API 发送请求。不确定这是为什么,但这是我的解决方案。

certificate-authority 相关推荐