0
我加載自定義字體在標題中這樣加載自定義字體:通過HTTP和HTTPS
<link rel="stylesheet" href="//example.com/stylesheets/custom-font.css"/>
在樣式表我有CSS的一個塊:
@font-face {
font-family: 'soneregular';
src: url('//example.com/fonts/webfont.eot');
src: url('//example.com/fonts/webfont.eot?#iefix') format('embedded-opentype'),
url('//example.com/fonts/webfont.woff2') format('woff2'),
url('//example.com/fonts/webfont.woff') format('woff'),
url('//example.com/fonts/webfont.ttf') format('truetype'),
url('//example.com/fonts/webfont.svg#soneregular') format('svg');
font-weight: normal;
font-style: normal;
}
當我有一個通過HTTP加載頁面時,自定義字體加載正常,但是當通過HTTPS加載頁面時,將恢復爲回退字體(無襯線)並在控制檯中顯示這些錯誤:
Mixed Content: The page at 'https://example.com/ecom/myAccount/myAccount.do?forward=/' was loaded over HTTPS, but requested an insecure font 'http://example.com/fonts/webfont.woff2'. This request has been blocked; the content must be served over HTTPS.
Mixed Content: The page at 'https://example.com/ecom/myAccount/myAccount.do?forward=/' was loaded over HTTPS, but requested an insecure font 'http://example.com/fonts/webfont.woff'. This request has been blocked; the content must be served over HTTPS.
Mixed Content: The page at 'https://example.com/ecom/myAccount/myAccount.do?forward=/' was loaded over HTTPS, but requested an insecure font 'http://example.com/fonts/webfont.ttf'. This request has been blocked; the content must be served over HTTPS.
我需要做些什麼才能使這些自定義字體通過HTTP和HTTPS正確加載?
我不擅長這個,但我認爲您需要看看您的服務器如何響應字體請求,如果您的網站運行的是https,則需要確保您的資產通過https服務也可能是你的服務器決定默認爲http,當沒有協議指定'// address.com'時 – SidOfc
哦 - 下面是一個答案,指的是特定的服務器配置,如果你至少可以共享這個名字你正在使用'apache'或'nginx'的服務器軟件,例如其他人可以幫助你更好的:) – SidOfc