@valbo/redirect-to-https-middleware
v1.0.1
Published
Express middleware that redirects HTTP to HTTPS
Downloads
1
Readme
@valbo/redirect-to-https-middleware
Express middleware that redirects HTTP to HTTPS.
Install
npm install @valbo/redirect-to-https-middleware
Usage
Add this middleware to your express app. To make it work behind a reverse proxy set trust proxy to true:
import { redirectToHttpsMiddleware } from '@valbo/redirect-to-https-middleware';
app.set('trust proxy', true);
app.use(redirectToHttpsMiddleware);
The middleware will redirect any request with the HTTP protocol to the same URL but with the HTTPS protocol, except if the server is localhost or 127.0.0.1.