I\'m trying to reroute http (80) to https (443) in my express app. I\'m using some middle ware to do this. If i go to my https://my-example-
http (80)
https (443)
https://my-example-
This should work.
app.use(function(req,resp,next){ if (req.headers['x-forwarded-proto'] == 'http') { return resp.redirect(301, 'https://' + req.headers.host + '/'); } else { return next(); } });