This package makes it easy to force HTTPS using Express. Since HTTPS is faster than HTTP. The package is generic but was built for the OSSPIM React Commerce boilerplate.
yarn add @osspim/elasticloadbalancer-express-force-https
const express = require('express');
const forceHttps = require('@osspim/elasticloadbalancer-express-force-https');
const server = express();
server.use(forceHttps());
Pass an optional options object if needed
Optional
Strip the leading www. from the host for both https and http requests
Optional
Redirect to a given hostname. Example from old-site.com to new-site.com:
redirectHostnames: {
'old-site.com': 'new-site.com'
}