I need to redirect all http requests to https including request to static files.
My code:
app.use(express.static(__dirname + '/public'));
app.get('*', function(req, res) {
if (!req.secure){
return res.redirect('https://' + config.domain + ":" + config.httpsPort + req.originalUrl);
}
res.sendFile(__dirname + '/public/index.html');
});
And redirect not working on static files. If I change order:
app.get(...);
app.use(...);
Then my static not working. How to redirect on such requests?