The browser refuses to load a font because of your Content Security Policy
Refused to load the font 'data:font/woff;base64,...' because it violates the following Content Security Policy directive: "default-src 'self'".Short answer
A font is blocked when the font-src directive, or default-src when font-src is missing, does not allow where the font comes from. For a data: font add data: to font-src. For a CDN font, add that host or self-host the font with next/font. Test the new policy in report-only mode first.
Fix it fast
1Find out which cause you have
Read the policy your server really sends, then find the font directive. If there is no font-src, default-src decides.
curl -sI https://example.com/ | grep -i content-security-policy2Match what you see, then jump to its fix
- 1
Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.No font-src, so default-src 'self' decidesFix - 2
The blocked URL in the message starts with data:font/.The font is inlined as a data: URI and data: is not allowedFix - 3
The blocked URL is an https:// font file on another host, for example a CDN.The font comes from an external hostFix
- 1
What does the error look like?
Refused to load the font 'data:font/woff;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.
Cause 1 of 3
No font-src, so default-src 'self' decides
1Check
MDN states that font-src falls back to default-src when it is absent. A policy of default-src 'self' therefore allows only fonts from your own origin.
curl -sI https://example.com/ | grep -i content-security-policy | tr ';' '\n' | grep -i -E "default-src|font-src"2Fix
Add an explicit font-src directive that lists the sources you really use. The Next.js CSP guide uses font-src 'self' in its starting policy.
// next.config.js
const csp = `
default-src 'self';
font-src 'self';
`
module.exports = {
async headers() {
return [{ source: '/(.*)', headers: [
{ key: 'Content-Security-Policy', value: csp.replace(/\n/g, '') },
] }]
},
}3Verify
Reload and check the response header lists font-src.
curl -sI http://localhost:3000/ | grep -i content-security-policyConfirmed by developer.mozilla.org
Cause 2 of 3
The font is inlined as a data: URI and data: is not allowed
1Check
A data: URI is its own scheme, so 'self' does not cover it. font-src accepts scheme sources, so data: can be listed.
curl -s https://example.com/ | grep -o "data:font[^;]*;" | head -32Fix
Add data: to font-src, or build the font as a normal file so it is served from your own origin.
font-src 'self' data:;3Verify
Hard-reload with the console open: the Refused to load the font line should be gone.
curl -sI http://localhost:3000/ | grep -i "font-src"Confirmed by developer.mozilla.org
Cause 3 of 3
The font comes from an external host
1Check
A host-source in font-src must match the host of the font file. A font from a host not listed is blocked, as the MDN example shows.
grep -rn "fonts.googleapis\|fonts.gstatic\|@font-face" app src styles 2>/dev/null | head2Fix
Preferably self-host: next/font downloads Google Fonts at build time and serves them from your own domain, so 'self' is enough. Otherwise add the font host to font-src.
// app/layout.tsx
import { Geist } from 'next/font/google'
const geist = Geist({ subsets: ['latin'] })
export default function RootLayout({ children }: { children: React.ReactNode }) {
return <html lang="en" className={geist.className}><body>{children}</body></html>
}3Verify
Open the network tab: the font file should load from your own origin.
npm run build && npm run startConfirmed by nextjs.org
How do I stop it coming back?
- Ship a new policy as Content-Security-Policy-Report-Only first, then enforce it when the reports are clean.
- Write font-src explicitly instead of leaning on default-src.
- Use next/font so fonts stay on your own origin.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Security
The browser blocks a script because of your Content Security Policy
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
The page's Content-Security-Policy does not allow what it tried to run or load.
5 causes, each with a fixSecurity
Inline base64 images do not show because of the Content Security Policy
Refused to load the image 'data:image/svg+xml;base64,...' because it violates the following Content Security Policy directive: "default-src 'self'".
A base64 image has a data: URL, and a policy such as default-src 'self' does not allow that scheme.
3 causes, each with a fixSecurity
Video from a MediaSource is blocked: 'Content at ... may not load data from blob:'
Content-Security-Policy: The page's settings blocked the loading of a resource (media-src) at blob:http://localhost:3000/...
A MediaSource video plays from a blob: URL.
3 causes, each with a fixSecurity
PHP LDAP in Laravel fails with Can't contact LDAP server over TLS
unable to get local issuer certificate
PHP's LDAP client uses OpenLDAP's settings.
3 causes, each with a fixSecurity
Your auth.log is full of Failed password and Invalid user attempts
Invalid user ubnt from 198.51.100.23 port 40122
Any public SSH port gets password guesses within hours; the log lines alone are not a breach.
4 causes, each with a fixSecurity
Entra ID token request fails: the request body must contain the parameter 'grant_type'
AADSTS900144: The request body must contain the following parameter: 'grant_type'.
The token endpoint did not find grant_type in the form body of your POST.
3 causes, each with a fix