vue的Mixed Content:The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure

Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure报错解决

问题产生

  • HTTPS页面中引入HTTP资源.
  • 在HTTPS页面里通过ajax的方式请求HTTP资源

解决办法

html页面中head加上这条
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

或者
回服务器应头中加上这个
header(“Content-Security-Policy: upgrade-insecure-requests”);

小伟科技 wechat
python爱好者公众号—每日学习python必备
欢迎打赏支持!