express-enforces-ssl

express-enforces-ssl

#Knowledge Base#Miscellaneous

A collection of binary tools for various purposes including linking, assembling, profiling, and more.

Visit Website

This Simple Module Enforces HTTPS Connections for Enhanced Security

This simple module ensures that all incoming requests use HTTPS connections. If a request comes in via non-encrypted HTTP, express-enforces-ssl automatically redirects it to an HTTPS address using a 301 permanent redirect. Additionally, express-enforces-ssl is compatible with reverse proxies (load balancers), which are commonly used by platforms like Heroku and nodejitsu. In these scenarios, it is essential to set the trustProxy parameter (see details below). Usage To get started, first install the module by running: $ npm install express-enforces-ssl --save Next, require the module and implement the HTTPS() method as follows: var express = require('express'); var http = require('http'); var express_enforces_ssl = require('express-enforces-ssl'); var app = express(); app.enable('trust proxy'); app.use(express_enforces_ssl()); /* Define Your Routes Here */ http.createServer(app).listen(app.get('port'), function() { console.log('Express server listening on port ' + app.get('port')); }); LICENSE MIT