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
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
Share Improve this question edited Mar 16, 2022 at 9:42 VLAZ 29.1k9 gold badges62 silver badges84 bronze badges asked Sep 22, 2020 at 17:25 ctbctb 1711 gold badge1 silver badge4 bronze badges 6Subsequently, I get this error on the webpage console: Failed to load resource: net::ERR_CONNECTION_CLOSED
- The server doesn't support https requests, when I'm testing the webpage on my local browser I don't have any problem, but when doing it on the webpage with SSL encryption then the error happens. – ctb Commented Sep 22, 2020 at 17:28
- What ?! you write in the ment the server "dosn't support https" and in your post, "the webpage has ssl encryption" ?! – Marc Commented Sep 22, 2020 at 17:35
- yes, the webpage hosting has SSL encryption. The server where the API resides doesn't support https requests – ctb Commented Sep 22, 2020 at 17:41
- I think your problem is CORS: en.wikipedia/wiki/Cross-origin_resource_sharing – Marc Commented Sep 23, 2020 at 6:18
- @Marc How can it be a CORS problem since the changes from http to https is done by the browser? – Karol Borkowski Commented Jun 30, 2021 at 10:53
1 Answer
Reset to default 13I 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.