我正在使用以下代码在客户端发出请求:
var request = new Request(`http://ip:8080/click?url=${value}`, {
method: 'GET',
headers: new Headers({
"Content-Type": "application/json"
}),
});
fetch(request)
但是当浏览器发出请求时,它会自动使用 https 协议(protocol)更改 URL:https://ip:8080/click?url=${value}
注意:网页有SSL加密
Subsequently, I get this error on the webpage console: Failed to load resource: net::ERR_CONNECTION_CLOSED
最佳答案
我遇到了同样的问题,原因是头部中的以下行:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
它用 https 替换每个 http 请求。
关于javascript fetch 自动将 http 更改为 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64014802/