package
express module for forcing https connections
npm install force-httpsGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
An Express module. Redirect or block requests made over external plain HTTP.
Probably won't work if you are using non standard ports on the public facing domain/interface
app.use(require('force-https'))Make sure to put it before any other middleware, especially app.router!
GET requests are redirected to their HTTPS equivalents
All other verbs receive an HTTP 409 with an error message, as HTTP states that one shouldn't redirect non GET requests
If you're behind a reverse proxy or load balancer (e.g Heroku, AWS ELB, Nginx, PaaS), you'll have to tell Express to trust the headers the proxy adds by adding app.enable('trust proxy'), otherwise this module will try to force the connection between the proxy and the express app to over https (which probably will not work).
All the other modules either seemed to either:
trust proxy setting and duplicate that functionality internally,POST and PUT requests,It isn't at all customisable, the error message is fixed, blah blah. I'm open to pull requests to change this.