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;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter