'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
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Karol Borkowski |
