var express = require('express'); var app = express(); app.enable('trust proxy'); //to detect if req.secure is true/false //Block http requests. Only allow https requests app.use(function (req, res, next) { if (req.headers['x-forwarded-proto'] !== 'https'){ return res.status(404).send('Not found'); } else { next(); } }) exports = module.exports = app;