-1

Problem

If i access my site via www.domain.tld the @font-face rule is omited. If i go to domain.tld (without the 'www' part) @font-face is regarded. All other css formattings are working in both cases fine.

CSS

@font-face {
    font-family: 'font-name';
    src: url(../fonts/font-name.eot);
    src: local("font-name"), url(../fonts/font-name.ttf) format("truetype");
}

Django

In my Django settings.py:

STATIC_ROOT = '/var/www/domain.tld/static/'
STATIC_URL = 'http://domain.tld/static/'

If i change it to STATIC_URL = 'http://www.domain.tld/static/' the @font-face rule is omited on domain.tld and regarded on www.domain.tld so it's the reverse behavior.

Apache

<VirtualHost *:80>
    CustomLog /var/log/apache2/domain.tld.log combined

    ServerName domain.tld
    ServerAlias www.domain.tld

    WSGIScriptAlias / /var/www/domain.tld/wsgi


    Alias /static/ /var/www/domain.tld/static/

    Alias /robots.txt /var/www/domain.tld/static/robots.txt
    Alias /favicon.ico /var/www/domain.tld/static/img/favicon.ico
</VirtualHost>
Ulfric Storm
  • 129
  • 2
  • 12

1 Answers1

1

cross-domain Web font embedding is denied by some browsers (not sure if it applies to all or some), and I believe this should remain as is (security wise). Apart from that, you don't need a FQDN either for STATIC_URL or MEDIA_URL your web server takes care serving static content, the url is used for providing a identifiable url for asset loading. So if you visit your website from a subdomain not everything is going to work if you have a FQDN in your static, remove the FQDN and just use the directory name you want, makes it easier also to port settings to a sandbox or a production system with multiple subdomains. You can also further check this stackoverflow question (there are some solutions provided, mind though that I don't know if its working as I never had such an issue):

@font-face fonts only work on their own domain

Community
  • 1
  • 1
petkostas
  • 6,890
  • 2
  • 25
  • 27