I am trying to write a code for redirecting all my Http requests to Https, now I wanted to ask I have seen below code on many different websites but some of them use return with res.redirect, some use return after res.redirect, some don't use anything and some use only next() after res.redirect.
I just want to ask what is the use of return or calling next() here. Or am I missing anything here ??
app.use(function(req,res,next) {
if(req.headers["x-forwarded-proto"] == "http") {
console.log('Request was HTTP');
/* return ??*/ res.redirect("https://" + req.headers.host + req.url);
// return or next() or nothing ??.
} else {
console.log('Request was not HTTP');
return next();
}
});