Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

redirect all request http to https express js

var app = express();

app.all('*', function(req, res, next){
    console.log('req start: ',req.secure, req.hostname, req.originalurl, app.get('port'));
    if (req.secure) {
        return next();
    }

    res.redirect('https://'+req.hostname + ':' + app.get('secPort') + req.originalurl);
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #redirect #request #http #https #express #js
ADD COMMENT
Topic
Name
8+5 =