Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-http-to-https

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-http-to-https

express-http-to-https is a node.js package for providing an Express middleware that redirects the client to HTTPS if they attempt to connect over HTTP.

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-13.72%
Maintainers
1
Weekly downloads
 
Created
Source

express-http-to-https

express-http-to-https is a node.js package for providing an Express middleware that redirects the client to HTTPS if they attempt to connect over HTTP.

Installation

$ npm install --save express-http-to-https

Usage

app.use(redirectToHTTPS(ignoreHosts, ignoreRoutes);

Configuration Options

  • ignoreHosts: An array of strings of the hostnames on which to not enable the redirect. note: you must include the port here, for example [/localhost:8080/].
  • ignoreRoutes: An array of strings of the routes on which not to enable the redirect.
  • redirectCode: The HTTP status code to return when redirecting. Defaults to 302 "found" can be any status code

Example

var express = require('express');
var app = express();

var redirectToHTTPS = require('express-http-to-https').redirectToHTTPS

// Don't redirect if the hostname is `localhost:port` or the route is `/insecure`
app.use(redirectToHTTPS([/localhost:(\d{4})/], [/\/insecure/], 301));

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.get('/insecure', function (req, res) {
  res.send('Dangerous!');
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

app.listen(8080, function () {
  console.log('Example app listening on port 8080 insecurely!');
});

JavaScript Style Guide

License

MIT License

Author

Max Walker (max@maxwalker.me)

Contributors

Aleksander Szmigiel

FAQs

Package last updated on 21 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc