fix: add font-src CSP directive and styled error page#22
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>
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
@fontsourceself-hosted fonts via@font-facedeclarations. Without an explicitfont-srcdirective, browsers fall back todefault-src— and even though the woff2 files are served from'self', some browsers block them with the error "font-src was not explicitly set, so default-src is used as a fallback. The action has been blocked." Addingfont-src 'self'todashboard/static/_headersunblocks them.+error.svelte, so any SvelteKit-level error (e.g. an API auth failure propagated through a load function) rendered on the browser's bare default error page — no layout, no padding, the status text touching the left edge. The new+error.svelterenders inside the root layout with the standard 24 px horizontal padding and uses the active theme's CSS tokens.Root cause of the 401
The
/api/projects401 Unauthorized in the console is not caused by this PR or #21 — the auth middleware code is unchanged. It means theCF_Authorizationcookie was absent or expired for that session. Re-authenticating through Cloudflare Access resolves it. The error page fix ensures that if it happens again the user sees a readable, on-brand message instead of the browser default.Test plan
npm run buildstill passes cleanly🤖 Generated with Claude Code