From a4ba23899e456de005af7cd65795e424fa3f5454 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 14 Oct 2020 14:26:57 -0400 Subject: [PATCH] feat: require https if nodebb is configured with https url --- src/routes/write/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/routes/write/index.js b/src/routes/write/index.js index c0764f6508..539db86b35 100644 --- a/src/routes/write/index.js +++ b/src/routes/write/index.js @@ -1,5 +1,6 @@ 'use strict'; +const nconf = require('nconf'); const middleware = require('../../middleware'); const helpers = require('../../controllers/helpers'); @@ -9,12 +10,11 @@ Write.reload = (params) => { const router = params.router; router.use('/api/v3', function (req, res, next) { - // if (req.protocol !== 'https') { - // res.set('Upgrade', 'TLS/1.0, HTTP/1.1'); - // return helpers.formatApiResponse(426, res); - // } else { - // next(); - // } + // Require https if configured so + if (nconf.get('secure') && req.protocol !== 'https') { + res.set('Upgrade', 'TLS/1.0, HTTP/1.1'); + return helpers.formatApiResponse(426, res); + } res.locals.isAPI = true; next();