2023-10-26 hexo部署到GitHub时css样式不生效 ==》 css文件链接被识别为不安全链接,导致无法生效
hexo d一键部署后查看效果发现博客页面的样式全丢失了,查看控制台发现了端倪:
Mixed Content: The page at 'https://xxx.github.io/' was loaded over HTTPS, but requested an insecure stylesheet 'http://xxx.com/lib/font-awesome/css/font-awesome.min.css?v=4.6.2'. This request has been blocked; the content must be served over HTTPS.
意思就是GitHub账号:https://xxx.github.io是https头的,而css文件存储的路径 http://xxx.com/lib/font-awesome/css/font-awesome.min.css?v=4.6.2
http开头的,被认为是不安全链接,故而无法加载。
解决方案:在博客根目录中找到index.html文件,添加下面代码,用于强制把http转换成https:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
============ 。。。。。。。。。。若干分钟后,我按了ctrl+f5强制刷新页面,结果就能正确显示了。。。。。连代码都不用加 ============
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
2022-10-26 2022-10-26 "getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json"
2022-10-26 2022-10-26 uniapp遍历绑定事件报错
2022-10-26 2022-10-26 [自动热重载错误] Cannot read property 'graph' of null TypeError: Cannot read property 'graph' of null