来源: 浏览器报Mixed Content错误的解决 – 简书
控制台报错:
Mixed Content: The page at ‘https://xxx.cn’ was loaded over HTTPS, but requested an insecure script ‘http://res.wx.qq.com/open/js/jweixin-1.6.0.js’. This request has been blocked; the content must be served over HTTPS.
解决方案
第一种
1.首先确定引入的资源可以在http和https下都能访问
比如:http://res.wx.qq.com/open/js/jweixin-1.6.0.js —> https://res.wx.qq.com/open/js/jweixin-1.6.0.js
2.在head里面写类似相对路径的形式
<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js" type="text/javascript"></script>
第二种
1.在页面中加入(meta)头中添加upgrade-insecure-requests
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
2.这将会把http请求转化为https请求。这样就不会再出现Mixed Content的错误了。
作者:jia林
链接:https://www.jianshu.com/p/0530240043e8
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。