HTTPS Redirect in Nodejs

EMBED

Saved by @mishka #javascript #nodejs #commandline

Step 0: Install the heroku-ssl-redirect package

npm install heroku-ssl-redirect
content_copyCOPY

Step 1: Add code to app.js in following order

var sslRedirect = require('heroku-ssl-redirect');
var express = require('express');
var app = express();

app.use(sslRedirect());

app.get('/', function(req, res){
  res.send('hello world');
});
content_copyCOPY
https://medium.com/@thiscodeworks.com/how-to-redirect-your-node-js-app-hosted-on-heroku-from-http-to-https-50ef80130bff