diff --git a/config.json b/config.json index 3409ed3..a8b6a96 100644 --- a/config.json +++ b/config.json @@ -24,5 +24,7 @@ "send": { "from": "mono@fyle.uk" } - } + }, + + "forceSSL": true } \ No newline at end of file diff --git a/src/server/index.ts b/src/server/index.ts index 89f4fe6..d5a7b53 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -28,6 +28,14 @@ app.use("/static/js",express.static("out/client")) 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}`) + else next() + }) +} + app.get("/server",(req,res) => { res.send(JSON.stringify({ ...config,