I have an ExpressJS / AngularJS site on Heroku and I use Express to redirect all non-https requests to the https version.
My problem is - I do not want to redirect the main page - everything else, yes. I want to just serve the homepage without https redirection. Any ideas how to do this with Express?
Thank you very much!
app.get('*',function(req,res,next){ if( req.headers['x-forwarded-proto'] != 'https' ) res.redirect('https://mydomain.com'+req.url) else next() }) app.use(express.static(__dirname)); app.listen(port);
source share