1 points · by amend · 8y ago · 2 comments
If the request is sent from the client as http, the following code should be added to ensure encryption on data sent.
/* Redirect http to https / app.get('', function(req,res,next) { if(req.headers['x-forwarded-proto'] != 'https' && process.env.NODE_ENV === 'production') res.redirect('https://'+req.hostname+req.url) else next() /* Continue to other routes if we're not redirecting */ });
Am I incorrect that that we should use an http app over https because heroku handles encryption?