feat(security): add baseline security response headers#18
Merged
Conversation
The site shipped none of the common security headers. Add a conservative set via next.config headers(), applied to every route: HSTS (2y, includeSubDomains, preload), X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy: strict-origin-when-cross-origin, and a Permissions-Policy denying camera, microphone, geolocation and browsing-topics (none are used by the app; verified no navigator.geolocation/getUserMedia usage). No Content-Security-Policy yet: a correct policy for the inline theme script, Google Fonts, Analytics, Turnstile and map tiles needs to be built and tested against the running app, so it is left as a dedicated follow-up rather than shipped as a guess that could break rendering. Co-Authored-By: Claude Opus 4.8 <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.
What
The site currently responds with none of the common security headers. This adds a conservative baseline via
next.config.tsheaders(), applied to every route:Strict-Transport-Securitymax-age=63072000; includeSubDomains; preloadX-Content-Type-OptionsnosniffX-Frame-OptionsSAMEORIGINReferrer-Policystrict-origin-when-cross-originPermissions-Policycamera=(), microphone=(), geolocation=(), browsing-topics=()Verified there is no
navigator.geolocation/getUserMediausage insrc/, so denying those features is safe.Deliberately out of scope: CSP
No
Content-Security-Policyin this PR. A correct CSP for this app has to account for the inline theme script (dangerouslySetInnerHTML), Google Fonts, Analytics, Turnstile and the map tile provider. Getting that wrong silently breaks rendering, so it deserves a dedicated PR built and tested against the running app rather than a guess shipped here.Verify
npx tsc --noEmitandeslint next.config.tspass.curl -sI https://packedplaces.com | grep -i strict-transportshould show the HSTS header.Third of the SEO/security cleanup sweep (see #16 metadataBase/OG images, #17 canonicals/hreflang).