npm.io
1.0.1 • Published 5 years ago

@valbo/redirect-to-https-middleware

Licence
MIT
Version
1.0.1
Deps
1
Size
15 kB
Vulns
0
Weekly
0

@valbo/redirect-to-https-middleware

Express middleware that redirects HTTP to HTTPS.

npm (scoped) semantic-release Build Status Coverage Status Known Vulnerabilities

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.

Keywords