Force SSL using Express
Force SSL (HTTPS) when HTTP is required using Express (Nodejs). Remove www and slash end on domain.
Installation
npm i ssl-express-www
Usage CommonJS
var express = require('express');
var secure = require('ssl-express-www');
var app = express();
app.use(secure);
var port = process.env.PORT || 3000;
app.listen(port, () => console.log('Server listening.'));
Usage ES6
Transpile it with Babel
import express from 'express';
import secure from 'ssl-express-www';
const app = express();
app.use(secure);
let port = process.env.PORT || 3000;
app.listen(port, () => console.log('Server listening.'));
Contributing
Babel@6 doesn't export default module.exports
any more.
npm i -D babel-plugin-add-module-exports
Usage in file .babelrc
{
"presets": ["env"],
"plugins": [
"add-module-exports"
]
}
License
This project is licensed under the MIT License - see the LICENSE file for details