fix: add security headers via helmet with CSP configuration#49
Merged
mayo-byte07 merged 2 commits intoMay 26, 2026
Merged
Conversation
- Add helmet middleware with Content Security Policy directives - Allow external resources: Google Fonts, Razorpay, CDNjs, Vercel analytics - Set frame-ancestors 'self' for admin live preview iframe - Refactor inline onclick to addEventListener for CSP compatibility - Blocks external framing, MIME sniffing, clickjacking - Enforces HTTPS via upgrade-insecure-requests
Contributor
|
@mayo-byte07 is attempting to deploy a commit to the Mayo's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Description
This PR adds HTTP security headers to the application using the
helmetmiddleware, significantly improving the app's security posture. A Content Security Policy (CSP) is configured to allow existing third-party resources (Google Fonts, Razorpay checkout, CDNjs, Vercel analytics) while blocking common attack vectors like XSS, clickjacking, and MIME sniffing. Also refactors an inline event handler for CSP compliance.Fixes #45
Changes Made
helmetv8.2.0 (package.json)const helmet = require('helmet')and configuredhelmet()middleware with CSP directives inserver.jsframe-ancestors: 'self'— allows admin live preview iframe to load/mewhile blocking external sites from framing Conn pagesupgrade-insecure-requests, blocks plugins viaobject-src: 'none', restricts form submissions viaform-action: 'self'onclick="window.open('/me', '_blank')"fromadmin.html(blocked by CSPscript-src-attr 'none')addEventListener('click', ...)for the share button inadmin.jsScreenshots (if applicable)
N/A
Checklist