mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 05:26:27 -08:00
Merge pull request #10 from nbitzz/express-ssl-force
Force SSL through expressjs
This commit is contained in:
commit
a4bbbf8d53
|
@ -24,5 +24,8 @@
|
|||
"send": {
|
||||
"from": "mono@fyle.uk"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"trustProxy": true,
|
||||
"forceSSL": true
|
||||
}
|
|
@ -28,6 +28,15 @@ app.use("/static/js",express.static("out/client"))
|
|||
|
||||
app.use(cookieParser())
|
||||
|
||||
// check for ssl, if not redirect
|
||||
if (config.trustProxy) app.enable("trust proxy")
|
||||
if (config.forceSSL) {
|
||||
app.use((req,res,next) => {
|
||||
if (req.protocol == "http") res.redirect(`https://${req.get("host")}${req.originalUrl}`)
|
||||
else next()
|
||||
})
|
||||
}
|
||||
|
||||
app.get("/server",(req,res) => {
|
||||
res.send(JSON.stringify({
|
||||
...config,
|
||||
|
|
Loading…
Reference in a new issue