Skip to content

valverdealbo/redirect-to-https-middleware

Repository files navigation

@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.

About

Express middleware that redirects HTTP to HTTPS

Resources

Stars

Watchers

Forks

Packages

No packages published