Google Web Fonts on HTTPS pages on Chrome

前端 未结 2 1122
情深已故
情深已故 2020-12-23 16:15

I\'m working on an ecommmerce project. Parts of the site are HTTP by default. Others, such as the checkout page, are HTTPS by default. On the HTTPS pages I\'m getting this m

相关标签:
2条回答
  • 2020-12-23 16:36

    Remove the protocol from your URL and let the browser determine it:

    <link href="//fonts.googleapis.com/css?family=PT+Sans" ...
    

    If your page is HTTPS, the font will be loaded from the HTTPS URL. If the page is HTTP, it'll be loaded from the HTTP URL.

    0 讨论(0)
  • 2020-12-23 16:39

    Create a schema agnostic url

    Change http://fonts.google... to //fonts.google...

    Drop the http: or https: from the front, the browser will use whichever schema you're currently using on the site.

    You may request resources using https from http, but not the other way round. An alternative to the above solution (and probably best practice) is to just always use https if it's available (which it must be if you're using this style of link, otherwise there no point in it anyway).

    0 讨论(0)
提交回复
热议问题