force-ssl: trustproxy

This commit is contained in:
May 2023-10-01 10:50:05 -07:00
parent 1d387de3dd
commit 3bf0e7491a
2 changed files with 2 additions and 0 deletions

View file

@ -26,5 +26,6 @@
} }
}, },
"trustProxy": true,
"forceSSL": true "forceSSL": true
} }

View file

@ -29,6 +29,7 @@ app.use("/static/js",express.static("out/client"))
app.use(cookieParser()) app.use(cookieParser())
// check for ssl, if not redirect // check for ssl, if not redirect
if (config.trustProxy) app.enable("trust proxy")
if (config.forceSSL) { if (config.forceSSL) {
app.use((req,res,next) => { app.use((req,res,next) => {
if (req.protocol == "http") res.redirect(`https://${req.get("host")}${req.originalUrl}`) if (req.protocol == "http") res.redirect(`https://${req.get("host")}${req.originalUrl}`)