force-ssl: switch to req.protocol?

This commit is contained in:
split / May 2023-10-01 10:40:03 -07:00
parent cb17eb1433
commit 1d387de3dd

View file

@ -31,7 +31,7 @@ app.use(cookieParser())
// check for ssl, if not redirect
if (config.forceSSL) {
app.use((req,res,next) => {
if (!req.secure) res.redirect(`https://${req.get("host")}${req.originalUrl}`)
if (req.protocol == "http") res.redirect(`https://${req.get("host")}${req.originalUrl}`)
else next()
})
}