方法一:
请求地址前获取 location.protocol 拿到当前的 http | https 替换到请求地址的前缀
如:http://www.com, location.protocol 获取到 http: | https,将地址分割动态拼 location.protocol
方法二:
获取location.protocol 动态创建meat标签
const protocol = location.protocol
if(protocol && protocol ==='https:') {
const meta = document.createElement('meta')
meta.httpEquiv = 'Content-Security-Policy'
meta.content = "upgrade-insecure-requests"
document.getElementsByTagName('head')[0].appendChild(meta);
}