Quantcast
Channel: How to deny direct access to font files used in CSS? - Webmasters Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Barry Pollard for How to deny direct access to font files used in CSS?

$
0
0

Well this is already done as best it can by default.

When you try to access fonts from another domain your browser will block this s a cross origin request (unless you explicitly add a "Access-Control-Allow-Origin" header in your htaccess file). Try it from a development server and you'll see what I mean as you'll get errors in the Console log of the browser. So it's not possible for visitors to reference fonts from your site in their CSS. This is a security feature, rather than a licencing issue but has the nice side effect of preventing people using fonts on your site.

However there is nothing technically stopping another site downloading the fonts from your site, and then uploading to their server and using them from their own domain*. This is because the browser has to be able to have access to the fonts (to display them on your site), and since they have access they can download them.

If you stop them being accessed at all, as you have tried, you'll break your site. Remember CSS is run on the client side, in the browser, not on the server side so the client needs access to the fonts.

So there is nothing you can really do here except check you are not allowing cross origin requests to your font with "Access-Control-Allow-Origin" header.

*This would of course mean that they are breaking copyright, but that is their problem not yours and not a technical issue.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>