This request has been blocked; the content must be served over HTTPS.


公司域名升级为https 之前获取ip信息的js报了错误

Mixed Content: The page at ‘https://www.xxx.com’ was loaded over HTTPS, but requested an insecure script ‘http://pv.sohu.com/cityjson?ie=utf-8’. This request has been blocked; the content must be served over HTTPS.

两种解决办法

1.

<script src="https://pv.sohu.com/cityjson"></script>
//改为
<script src="//pv.sohu.com/cityjson"></script>

链接以 // 开头,是使用 “相对协议”,也就是前面省去了 http: 或 https:

这样做的好处是浏览器能够根据你的网站所采用的协议来自动加载 CDN 上托管的文件

  1. 在页面中加入meta头:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

意思是让浏览器自动升级请求