在https页面上通过http加载Chrome脚本

Nik*_*nyh 5 html javascript ssl https google-chrome

我们在模板中有绝对路径,即:

<link rel="stylesheet" href="/media/css/ui.css?v=3" />
Run Code Online (Sandbox Code Playgroud)

当我试图打开https页面时 - 我收到以下错误:

[blocked] The page at 'https://{{ full_site }}/{{secure_page}}' was loaded over HTTPS, 
but ran insecure content from 'http://{{full_site }}/media/css/ui.css?v=3': 
this content should also be loaded over HTTPS.
Run Code Online (Sandbox Code Playgroud)

但路径https://{{full_site }}/media/css/ui.css?v=3可用......

告诉我,为什么chrome尝试在https页面上通过http加载内容?以及如何强制它在相对路径上通过https加载脚本?

UPD页面在firefox中完美加载.所以这只是铬问题.所有路径都是相对的.

sac*_*024 4

这可能是您的 CSS 文件可能通过加载不安全内容(来自 HTTP 服务器的内容)的属性ui.css引用资源(例如图像)的原因background or background-image

如果您的网站上有资源,请使用相对协议链接,例如

url(//example.com/images/some_image.png)
Run Code Online (Sandbox Code Playgroud)

同样,更新您的链接以使用相关协议链接,例如

<link rel="stylesheet" href="//{{full site}}/media/css/ui.css?v=3" />
Run Code Online (Sandbox Code Playgroud)