Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use strict https in production #410

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

frankieroberto
Copy link
Contributor

@frankieroberto frankieroberto commented Nov 13, 2024

This aims to avoid browser warnings if users accidentally visit a prototype in non-secure mode.

It does this by adding the Strict-Transport-Security HTTP header.

This will ensure that once a browser has successfully loaded a first page from the domain over https, all subsequent requests will automatically use https, even if the http:// prefix is typed into the URL bar.

I’ve set this to require NODE_ENV to be set to production to avoid any issues when running the prototype over localhost. We’d have to add this to the documentation. However many platforms such as Heroku will set this by default for Node.js apps.

Once your prototype is running with the header set, you can also submit the domain to https://hstspreload.org/ (although this doesn't work for subdomains) which will ensure the browsers at it to their list of domains to always use https on without even having to visit it first.

Fixes #141

Checklist

  • CHANGELOG entry

This will ensure that browsers automatically load the prototype over https, even if the `http://` prefix is typed into the URL bar.

It does require `NODE_ENV` to be set to `production`, however many platforms such as Heroku will [set this by default](https://devcenter.heroku.com/changelog-items/688) for Node.js apps.

Once this is set you can also submit the domain to https://hstspreload.org which will ensure the browsers at it to their list of domains to always use https on.
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.

Force https when running in production
1 participant