Repository navigation
fix(deploy): CORP, a narrow CSP, immutable asset caching and a deploy check - #1859
Merged
Merged
Conversation
… check Ported from the old deploy-hardening branch onto main: - every host sends Cross-Origin-Resource-Policy: same-origin and a CSP with no fetch directives (base-uri, object-src, frame-ancestors, form-action), so it can't block the FFmpeg cores or analytics; - /_next/static/* is cached for a year as immutable, declared rather than left to the Netlify Next.js plugin; - scripts/deploy/check-deploy.mjs checks a deployed or local site: headers, MIME types and caching on the page, a script, the font, the FFmpeg worker chunk, the engine WASM, the trailing-slash redirect and a 404, and with --expect-commit that the build is the right one (stamped in <meta name="reframe-build">); - deploy-smoke.yml runs it on every PR against a local build and against Netlify deploy previews; - the local test server sends the declared headers, caching and redirect.
✅ Deploy Preview for reframe-os ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
# Conflicts: # netlify.toml # public/_headers # src/app/layout.tsx # vercel.json
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.
Phase 6: the deploy headers and caching work from the old
feat/deploy-hardening/fix/release-hardeningbranches, ported as a fresh PR on main. Commit-stamped builds were already on main (NEXT_PUBLIC_RELEASE); this adds the rest.Headers
All three hosts get the same set:
netlify.toml(canonical),public/_headersandvercel.json.deployConfig.test.tskeeps them identical.Cross-Origin-Resource-Policy: same-origin: other sites can't embed Reframe's files.Content-Security-Policy: base-uri 'self'; object-src 'none'; frame-ancestors 'none'; form-action 'self'script-src,connect-src…), so the policy can't block the FFmpeg cores or Datadog RUM.<base>hijacking and off-site form posts. The footer's email form doesn't submit anywhere, soform-action 'self'is safe.Cache-Control: public, max-age=31536000, immutableon/_next/static/*, whose names change with their content. Before, this depended on the Netlify Next.js plugin being enabled in the UI; a deploy without the plugin served them withmax-age=0.Deployment check
scripts/deploy/check-deploy.mjs <url> [--expect-commit <sha>] [--json], with pure rules inscripts/deploy/lib/deployCheck.mjs./privacy/→/privacyredirect and a 404.--expect-commit, it compares the build stamp in<meta name="reframe-build">(added to the layout fromNEXT_PUBLIC_RELEASE). A stale deploy, an unstamped one or adevone fails..github/workflows/deploy-smoke.yml, read-only with no secrets:out/locally with the declared headers and runs the check with--expect-commit $GITHUB_SHA.statusevents it checks the deploy preview. GitHub only runs status-triggered workflows from the default branch, so that part starts working once this is on main.scripts/serve-isolated.mjs(Playwright and the smoke test) now sends the declared headers fromvercel.jsoninstead of only COOP/COEP. It also sets the hosts' caching and the trailing-slash redirect.ISOLATED=0still drops COOP/COEP for the single-threaded project.Tests
src/lib/tests/deployCheck.test.ts: the rules, plus the CLI run against a real local server (good, missing header, stale commit, needs login, unreachable, bad usage).deployConfig.test.ts: CORP, the CSP's directives, and immutable caching in both Netlify files.vitest.setup.tsskips thewindowpolyfill in node-environment tests.Docs
docs/DEPLOYMENT.md: the deploy check, the smoke workflow, and what each header is for.After this is merged I'll run the check against the live site.