From 63ac3169590f196a1fc47d8f55e9e9659e1e9810 Mon Sep 17 00:00:00 2001 From: gocivici Date: Wed, 27 Sep 2023 13:56:42 +0300 Subject: [PATCH] https redirect --- backend.js | 9 +++++++++ public/ghost2.png | Bin 0 -> 2128 bytes public/index.js | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 public/ghost2.png diff --git a/backend.js b/backend.js index 8e379b5..6cf3a73 100644 --- a/backend.js +++ b/backend.js @@ -11,6 +11,15 @@ const io = new Server(server, { pingTimeout:5000 }) +app.use(requireHTTPS); + +function requireHTTPS(req, res, next) { + // The 'x-forwarded-proto' check is for Heroku + if (!req.secure && req.get('x-forwarded-proto') !== 'https' && process.env.NODE_ENV !== "development") { + return res.redirect('https://' + req.get('host') + req.url); + } + next(); + } // const port = 3000 app.use(express.static('public')) diff --git a/public/ghost2.png b/public/ghost2.png new file mode 100644 index 0000000000000000000000000000000000000000..f020105101272f518784009607bbb1fd9df16317 GIT binary patch literal 2128 zcmV-W2(R~vP)Px-3Q0skRCt{2oquc;Wg5r7&vfgm74m{5MF`RaKsIwD$Iu1B( z4glEy*{1-2%F0T1RY;K;v#w(RuB8Y14=*yA3;>+xx|jlWi39_1Bs~D^+WRq#ii+G} z(r^>BKaRxLU7S6;-^W|;?((c&^%Ylui26J$XoH}|af1YZ9Eq>FIO74}N0TNgHR?Na z2FX|)txJ~{tlRR=+u6JIZo}C@f;euF;ExmWwH7B5iF|v(g%{>6Tk+WANXFv0@#nKk zwrfmW1psK06_HrlK{;#X5?)!@48v8Iv}DQ zt_qYvia1V@;*YBMT8l$OU!A+mG_AbHlO|6tTj$zy_BqSrD^>u&^^U^XM2a{L5#x`N z_#;4^i5uU1BX7a(egDpT{PL?Ci#E)jZyr}wg>^5#RCJqP-F2r25r;&KI1X!z@ke#U z*IgXc*3}g(>*zXyhn6qL-p>CF*|wwW2zKrLxNIMWVJvYRa0n!c;}9|aC|&U)A})2M z?fGX`<2U!+i)b{eQnG+#EDj=Su`Fw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