ctb
ctb

Reputation: 171

javascript fetch automatically changes http with https

I am making a request with fetch at the client side with this code:

    var request = new Request(`http://ip:8080/click?url=${value}`, {
        method: 'GET',
        headers: new Headers({
            "Content-Type": "application/json"
        }),
    });
    fetch(request)

but when the browser makes the request, it automatically changes the URL with https protocol:

https://ip:8080/click?url=${value}

Note: the webpage has SSL encryption

Subsequently, I get this error on the webpage console: Failed to load resource: net::ERR_CONNECTION_CLOSED

Upvotes: 17

Views: 13138

Answers (1)

Karol Borkowski
Karol Borkowski

Reputation: 742

I had the same problem and the reason was the following line in the head section:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

It replaces every http requests with https.

Upvotes: 13

Related Questions