fix: serve fonts from static/fonts/ to fix CSP violation#23
Merged
Conversation
The themed redesign added self-hosted @fontsource fonts via @font-face declarations. Without an explicit font-src directive the browser falls back to default-src and blocks the woff2 files even though they are served from 'self'. Adding font-src 'self' to _headers unblocks them. Also adds +error.svelte so SvelteKit error states (e.g. API auth failures) render inside the root layout with the correct 24px horizontal padding and theme-aware colours, rather than falling through to the bare default error page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fontsource CSS imports caused Vite to embed font files as Base64 data URIs in the JS bundle, which are blocked by font-src 'self'. Replaces the npm package imports with custom @font-face declarations referencing woff2 files copied to static/fonts/ — served as plain same-origin assets at /fonts/*.woff2. Drops @fontsource/inter and @fontsource/jetbrains-mono from package.json; latin-only subset reduces the font payload from 80+ files to 7. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@fontsourceCSS imports caused Vite to embed font files as Base64 data URIs in the JS bundle;font-src 'self'does not coverdata:URIs, so every font load was blocked@font-facedeclarations inapp.csspointing to/fonts/*.woff2(absolute, same-origin paths)dashboard/static/fonts/so they ship as plain static assets@fontsource/interand@fontsource/jetbrains-monofrompackage.json— no longer neededTest plan
/fonts/inter-400.woff2(and siblings) return 200 from the deployed Workerdata:font-src violations appear in DevTools → Console after a hard refresh🤖 Generated with Claude Code