From 76df151507a66352d04de9dfcbf05599614a00cb Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sun, 9 Jul 2023 12:59:12 -0300 Subject: [PATCH] fix(all): Minor changes in PROD. --- src/app.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app.ts b/src/app.ts index 95383f03..01fb6dc2 100644 --- a/src/app.ts +++ b/src/app.ts @@ -104,15 +104,6 @@ export class GBServer { server.use(bodyParser.json()); server.use(bodyParser.urlencoded({ extended: true })); - // Setups unsecure http redirect. - - server.use(function (request, response, next) { - if (process.env.NODE_ENV != 'development' && !request.secure) { - return response.redirect("https://" + request.headers.host + request.url); - } - next(); - }); - // Setups global error handlers. process.on('unhandledRejection', (err, p) => { @@ -287,6 +278,18 @@ export class GBServer { })(); }; + // Setups unsecure http redirect. + + const httpServer = express(); + httpServer.use(function (request, response, next) { + if (process.env.NODE_ENV != 'development' && !request.secure) { + return response.redirect("https://" + request.headers.host + request.url); + } + next(); + }); + + + if (process.env.CERTIFICATE_PFX) { const options1 = { passphrase: process.env.CERTIFICATE_PASSPHRASE,