UNPKG

guox-express

Version:

GuOx: Ultimate enterprise‑grade, AI & WASM‑powered Express security framework

10 lines (9 loc) 384 B
import { RequestHandler } from 'express'; export default function HTTPSRedirect(): RequestHandler { const mw: RequestHandler = (req, res, next) => { if (req.secure || req.get('X-Forwarded-Proto')==='https') return next(); res.redirect(301, `https://${req.get('Host')}${req.originalUrl}`); }; Object.defineProperty(mw, 'name', { value: 'HTTPSRedirect' }); return mw; }