index.js
function ensureSecure(req, res, next){
  if(req.headers["x-forwarded-proto"] === "https"){
  // OK, continue
  return next();
};
res.redirect('https://'+req.hostname+req.url);
}
function ensureSecure(req, res, next){
  if(req.headers["x-forwarded-proto"] === "https"){
  // OK, continue
  return next();
};
res.redirect('https://'+req.hostname+req.url);
}
/////////////////////////////////////////// /////   HTTPS TRAFFIC REDIRECT    //////// ///////////////////////////////////////// Redirect all HTTP traffic to HTTPS