0

As with @import url(...), a remote domain can be provided in the url specified when importing a font with @font-face: { src: url(...) }.

For example:

/*声明 WebFont*/
@font-face {
  font-family: 'source';
  src: url('https://some/remote/domain/font/source.eot');
    ...
}

Specifying a remote domain results in a browser error by default. What is the reason for this restriction?

skomisa
  • 16,436
  • 7
  • 61
  • 102
flyflydogdog
  • 307
  • 3
  • 10
  • I reworded and clarified the question. – skomisa Mar 03 '19 at 02:34
  • Though not a duplicate, [Cross-domain font-face issues](https://stackoverflow.com/q/8245464/2985643) may be relevant. – skomisa Mar 03 '19 at 02:38
  • @skomisa thank u saving my poor English. I wanna know why browser have that strategy. – flyflydogdog Mar 04 '19 at 08:45
  • The reason that browsers don't allow this is [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). See this [_"Cross Domain Fonts"_](https://zinoui.com/blog/cross-domain-fonts) article for a brief explanation, and how to resolve it. Firefox links to this [_"What Went Wrong"_](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin?utm_source=devtools&utm_medium=firefox-cors-errors&utm_campaign=default) article in a Console error message when you try to load your load your page with `@font-face` specifying a remote domain. Does that clarify the situation? – skomisa Mar 04 '19 at 09:08
  • @skomisa clear! understand ! – flyflydogdog Mar 04 '19 at 09:18

0 Answers0