Search code examples
javascriptgetfetchssl-certificatecertificate-authority

net::ERR_CERT_AUTHORITY_INVALID with JavaScript fetch request on new Microsoft Edge


Having an issue when trying to perform a fetch request.

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);
        });

This is my request I'm sending and here is the error I'm getting.

GET https://localhost:5001/api/Blog/ net::ERR_CERT_AUTHORITY_INVALID

Anyone know how I can get around this error. Note: I have tested the request on 2 other computers and this worked fine.


Solution

  • By changing my GET request to mode: "cors" and also trusting my API in trusted root authorities. I was able to send a request to the API. Unsure why this is but it was my solution.