Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

http to https redirect 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: #http #https #redirect #express #js
ADD COMMENT
Topic
Name
1+9 =