Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set font-face data: in a Content Security Policy meta tag?

I am using a very small embedded font in a CSS file like so:

@font-face {
    font-family: 'fontello';
    src: url('data:application/octet-stream;base64,...');
}

But upon loading the page in Chrome, I get this error in the console, and the font is not loading.

Refused to load the font 'data:application/octet-stream;base64,...' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.

I am using the following meta tags:

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; font-src data:" />
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; font-src data:" />
<meta http-equiv="X-WebKit-CSP" content="default-src 'self'; font-src data:" />

I did some research on CSP and the meta tags I've added seem like they should work, but so far nothing has changed. I explicity set font-src and yet the error message say that I haven't. What am I doing wrong?

like image 666
FiniteLooper Avatar asked Nov 25 '25 22:11

FiniteLooper


1 Answers

eject this snippet within the head, if you set font explicitly or you can play with "font-src".

<meta http-equiv="Content-Security-Policy" content="font-src 
https://* data:;" />
like image 113
Huseyin Avatar answered Nov 27 '25 12:11

Huseyin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!