与自定义域名一起使用github页面时出现混合内容错误

与自定义域名一起使用github页面时出现混合内容错误

问题描述:

我正在使用Cloudflare自定义域名(https://thebotspeaks.com)托管我的git-hub页面网站(peps09791.github.io)。 要启用HTTPS,我也做了以下配置:与自定义域名一起使用github页面时出现混合内容错误

  1. 在我_config.yaml文件 我已经设置了URL键相应

    URL: “https://peps0791.github.io

  2. 从我的CloudFlare仪表板,我启用了HTTPS重写选项以防止混合内容错误。

  3. 我也从CloudFlare启用了灵活的SSL。

我还没有启用默认的HTTPS重定向,因为网站突破了HTTPS。在HTTP上,它工作正常。

现在,当我尝试使用HTTPS访问我的网站,我收到混合内容错误:

Mixed Content: The page at ' https://thebotspeaks.com/ ' was loaded over HTTPS, but requested an insecure image ' http://thebotspeaks.com/assets/images/bio-photo.jpg '. This content should also be served over HTTPS.

09:54:45.323 (index):1 Mixed Content: The page at ' https://thebotspeaks.com/ ' was loaded over HTTPS, but requested an insecure stylesheet ' http://thebotspeaks.com/assets/css/main.css '. This request has been blocked; the content must be served over HTTPS.

09:54:45.785 (index):1 Mixed Content: The page at ' https://thebotspeaks.com/ ' was loaded over HTTPS, but requested an insecure script ' http://thebotspeaks.com/assets/js/main.min.js '. This request has been blocked; the content must be served over HTTPS.

从控制台上,我可以看到这一点:

<script src="https://peps0791.github.io/assets/js/main.min.js"></script> 

<link rel="stylesheet" href="https://peps0791.github.io/assets/css/main.css"> 

我该如何解决这个问题 ?

这里的问题是您的资产(即您的CSS或JavaScript)将重定向到您网站的HTTP版本。这是因为您的资产直接引用了您的GitHub网站,而不是启用了Cloudflare的网域。

例如;你的HTML在https://peps0791.github.io/assets/css/main.css,而不是引用的https://thebotspeaks.com/assets/css/main.css

你的CSS文件,为了解决这个问题,它看起来像你需要更新你的_config.yaml文件有下列URL键:

url: "https://thebotspeaks.com" 

比较一般有关解决各种混合内容问题的建议可以在Cloudflare知识库的以下文章中找到:How do I fix the SSL Mixed Content Error Message?

+0

将URL更改为自定义域为我工作。 谢谢! – Peps0791