查了很多资料说index.html
里的<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
删掉就可以了,但是我项目里根本没有这一句。
在index.html
里加上<meta http-equiv="Content-Security-Policy">
也没用。
最后解决办法:
前端用函数处理地址,用nginx反向代理至正确的地址
前提是必须有一个可以用的https域名
前端处理地址的函数:
getHttpsUrl(url) {
if (url)
return url.replace(
"http://<静态资源地址>",
"https://<你的域名>/<反向代理路径>/"
//反向代理路径可以随意自己命名
);
else return "";
},
nginx配置文件:
server {
listen 443 ssl;
server_name <你的域名>;
location /<反向代理路径>/{
proxy_pass http://<静态资源地址>;
}
}