Skip to content

fix(server): add app-wide browser security headers - #2060

Draft
bestony wants to merge 2 commits into
mainfrom
fix/1541-fastify-security-headers
Draft

fix(server): add app-wide browser security headers#2060
bestony wants to merge 2 commits into
mainfrom
fix/1541-fastify-security-headers

Conversation

@bestony

@bestony bestony commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Enforce app-wide CSP, HSTS, nosniff, referrer, frame, and permissions headers before all Fastify API and SPA routes.
  • Keep the policy compatible with the current same-origin API and WebSocket flow and the production GA4, Clarity, and Sentry endpoints.
  • Move inline theme and analytics bootstrap code into a same-origin static asset so the CSP can reject inline scripts.
  • Add integration coverage for API, static asset, SPA fallback, error, and HEAD responses, plus bootstrap regression coverage.

Verification

  • pnpm check
  • pnpm typecheck
  • pnpm build
  • GIT_CONFIG_GLOBAL=<clean config> TMPDIR=/private/tmp pnpm exec turbo run test --env-mode=loose (12/12 tasks passed under Node.js 24)

QA

Formal QA was not run. This change affects server and web response behavior. A production browser pass should check the CSP console, GA4, Clarity, Sentry, same-origin API calls, and WebSocket reconnects.

Closes #1541

@bestony bestony added the fire_submitted GoF: PR submitted for maintainer review (stays draft) label Jul 29, 2026
Comment thread packages/web/src/__tests__/browser-bootstrap.test.ts Fixed
describe("browser bootstrap", () => {
it("keeps index.html free of inline executable scripts", async () => {
const indexHtml = await readFile(indexHtmlUrl, "utf8");
const scripts = Array.from(indexHtml.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/giu)).map((match) => ({
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fire_submitted GoF: PR submitted for maintainer review (stays draft)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add app-wide browser security headers for Fastify/SPA

2 participants