Skip to content

security: enforce HTTPS with HSTS via Helmet - #953

Open
Sarthak816 wants to merge 1 commit into
parthbuilds-community:mainfrom
Sarthak816:feat/hsts-helmet-950
Open

security: enforce HTTPS with HSTS via Helmet#953
Sarthak816 wants to merge 1 commit into
parthbuilds-community:mainfrom
Sarthak816:feat/hsts-helmet-950

Conversation

@Sarthak816

Copy link
Copy Markdown
Contributor

Closes #950

Summary

Explicitly configures HTTP Strict Transport Security (HSTS) in the Express server so browsers refuse to connect to the API over plain HTTP, blocking MITM downgrade attacks.

Changes

  • server/index.js: replaced the default app.use(helmet()) HSTS settings (180-day max-age) with an explicit strictTransportSecurity config: maxAge: 31536000 (1 year), includeSubDomains: true, and preload: true.

Resulting header

Verified against a live server:

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

Notes

  • Browsers only honor the header over HTTPS, so this is safe in dev (plain HTTP) too.
  • preload: true opts the domain into the HSTS preload list; the domain must also be submitted to https://hstspreload.org before preload takes effect.

Validation

  • Backend test suite passes (78 tests, 3 suites)
  • Verified the exact header value with an in-memory Express server

Explicitly configure Strict Transport Security through helmet's
strictTransportSecurity option, replacing the default HSTS settings
(180 days) with a one-year maxAge including subdomains and the
preload flag, so browsers refuse plain-HTTP connections to the API
and MITM downgrade attacks are blocked.

Closes parthbuilds-community#950
@github-actions github-actions Bot added refactor Improve code without changing functionality backend labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend refactor Improve code without changing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: Enforce HTTPS using HSTS (HTTP Strict Transport Security)

1 participant