错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure......._cczzyc1的博客-CSDN博客

baacloud免费翻墙vpn注册使用

来源: 错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure……._cczzyc1的博客-CSDN博客

HTTPS页面里动态的引入HTTP资源,比如引入一个js文件,会被直接block掉的.在HTTPS页面里通过AJAX的方式请求HTTP资源,也会被直接block掉的。

Mixed Content: The page at ‘xxx’ was loaded over HTTPS, but requested an insecure resource ‘xxx’. This request has been blocked; the content must be served over HTTPS.

解决办法:

页面的head中加入:

<meta http-equiv=”Content-Security-Policy” content=”upgrade-insecure-requests”>

意思是自动将http的不安全请求升级为https

注意:在需要的网页上加上面的语句,

其它不需要的网页不需要加,不然后了出错的。

CSP设置upgrade-insecure-requests

好在 W3C 工作组考虑到了我们升级 HTTPS 的艰难,在 2015 年 4 月份就出了一个 Upgrade Insecure Requests 的草案,他的作用就是让浏览器自动升级请求。

在我们服务器的响应头中加入:

header("Content-Security-Policy: upgrade-insecure-requests");
  • 1

 

转载:https://blog.csdn.net/u012259256/article/details/72039950

https://www.cnblogs.com/hustskyking/p/upgrade-insecure-requests.html

https://blog.csdn.net/haibo0668/article/details/82947917





赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏