Loading... **错误信息:** Mixed Content: The [page](https://so.csdn.net/so/search?q=page&spm=1001.2101.3001.7020) at 'https://wshop.xxx.com/wxshop/' was loaded over HTTPS, but requested an insecure image '[http](https://so.csdn.net/so/search?q=http&spm=1001.2101.3001.7020)://wshop.xxx.com/wxshop//image/A3.jpg'. This content should also be served over [HTTPS](https://so.csdn.net/so/search?q=HTTPS&spm=1001.2101.3001.7020). **报错原因:** HTTPS 是 HTTP over Secure Socket Layer,以安全为目标的 HTTP 通道,所以在 HTTPS 承载的页面上不允许出现 http 请求,一旦出现就是提示或报错 ![](https://img-blog.csdnimg.cn/20190319102305771.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NfbW9uc3Rlcl8=,size_16,color_FFFFFF,t_70) **解决办法:** **CSP设置upgrade-insecure-requests** 方法1: 好在 W3C 工作组考虑到了我们升级 HTTPS 的艰难,在 2015 年 4 月份就出了一个 `Upgrade Insecure Requests` 的[草案](http://www.w3.org/TR/mixed-content/),他的作用就是让浏览器自动升级请求。 在我们服务器的响应头中加入:(当然我操作不了服务器,下面还会介绍另一种解决办法) ```html hljs language-xml header("Content-Security-Policy: upgrade-insecure-requests"); ``` 方法2: 在页面中加入 `meta` 头:(我使用这个方法) ```html hljs language-xml <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> ``` ![](https://img-blog.csdnimg.cn/20190319103144967.png) (如果页面比较多,需要统一改变的话,我们可以将这条语句添加到全局JS文件里,全局调用) ![](https://img-blog.csdnimg.cn/20190419110210674.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NfbW9uc3Rlcl8=,size_16,color_FFFFFF,t_70) 方法3: 删除链接中的“https:” 这样的话系统就会自动的动态配置http 和 https。 ![](https://img-blog.csdnimg.cn/20190319111425635.png) 相关文章 * [http://www.w3.org/TR/mixed-content/](http://www.w3.org/TR/mixed-content/) * [https://www.chromestatus.com/feature/6534575509471232](https://www.chromestatus.com/feature/6534575509471232) 最后修改:2022 年 03 月 15 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 0 如果觉得我的文章对你有用,请随意赞赏