how google bypasses the 'no cross-domain custom fonts' on Firefox
-
15-03-2021 - |
Question
I want to have a small Webfont Service on our web site to be used by our customers.
I just want to know how Google bypasses cross-domain prohibition problem for font downloading ?
edit:
I put this CSS
on the server:
@font-face {
font-family: 'Fascinate';
font-style: normal;
font-weight: 400;
src: local('Fascinate'), local('Fascinate-Regular'), url('http://www.site.com/fontkit/fonts/fascinate.woff') format('woff');
}
and import it in localhost as below
<link href='http://www.site.com/fontkit/style.css' rel='stylesheet' type='text/css'>
this does not work but when i change the font url to google fonts, it works correctly. like this :
src: local('Fascinate'), local('Fascinate-Regular'), url('http://themes.googleusercontent.com/static/fonts/fascinate/v1/NnlsYos1mCtA9prs2JfnBT8E0i7KZn-EPnyo3HZu7kw.woff') format('woff');
Solution 2
Adding some codes to .htaccess
(On the server) solved the problem
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET"
Header set Access-Control-Allow-Credentials "false"
</IfModule>
OTHER TIPS
You're allowed to request scripts and styles from other sites, the same-origin policy prohibits sending requests with javascript to/from a different domain via something like Ajax.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow