1 works

HTTPS Redirect in Nodejs


dashboard

Posted by @mishka #javascript #nodejs #commandline

Step 0: Install the heroku-ssl-redirect package

npm install heroku-ssl-redirect
content_copyCopy to Clipboard

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 to Clipboard https://medium.com/@thiscodeworks.com/how-to-redirect-your-node-js-app-hosted-on-heroku-from-http-to-https-50ef80130bff

>> Browse more code snippets

more_vert