Skip to content

feat: add security headers middleware (#318)#459

Open
elenajoyce wants to merge 1 commit into
devEunicee:mainfrom
elenajoyce:feature/318-security-headers
Open

feat: add security headers middleware (#318)#459
elenajoyce wants to merge 1 commit into
devEunicee:mainfrom
elenajoyce:feature/318-security-headers

Conversation

@elenajoyce

Copy link
Copy Markdown

Summary

Adds security headers middleware to protect the API against common web attacks.

Changes

  • api/src/middleware/securityHeaders.js — sets all required headers:
    • Content-Security-Policy
    • Strict-Transport-Security (HSTS — production only)
    • X-Frame-Options: DENY
    • X-Content-Type-Options: nosniff
    • X-XSS-Protection: 1; mode=block
    • Referrer-Policy: strict-origin-when-cross-origin
    • Permissions-Policy (disables geolocation, microphone, camera, payment, usb)
  • api/src/server.js — wired as first middleware before all routes
  • CSP string and HSTS toggle configurable via options object

Acceptance criteria

  • Content-Security-Policy
  • Strict-Transport-Security (HSTS)
  • X-Frame-Options
  • X-Content-Type-Options
  • X-XSS-Protection
  • Referrer-Policy
  • Permissions-Policy
  • Configurable / testable without HSTS in dev

Closes #318

- securityHeaders.js sets CSP, HSTS, X-Frame-Options, X-Content-Type-Options,
  X-XSS-Protection, Referrer-Policy, Permissions-Policy
- HSTS only sent in production (NODE_ENV=production)
- CSP and HSTS are configurable via options object
- Wired into server.js as first middleware before all routes

Closes devEunicee#318
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@elenajoyce Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#318 - Create Security Headers Middleware

1 participant