Skip to content

Mixed Content: The page at 'xxx' was loaded over HTTPS, but requested an insecure resource 'xxx'.

HTTPS页面里动态的引入HTTP资源,比如引入一个js文件,会被直接block掉的.在HTTPS页面里通过AJAX的方式请求HTTP资源,也会被直接block掉的。 非https连接内容会被blocked掉 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中加入:

html
<meta
  http-equiv="Content-Security-Policy"
  content="upgrade-insecure-requests"
/>

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

CSP设置upgrade-insecure-requests

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

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

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

转载: https://blog.csdn.net/u012259256/article/details/72039950https://www.cnblogs.com/hustskyking/p/upgrade-insecure-requests.html

上次更新于: