From e4630199a6a5a809918492de06437b0558df999f Mon Sep 17 00:00:00 2001 From: shockrah Date: Fri, 12 Feb 2021 19:07:14 -0800 Subject: [PATCH] Only using http in dev environments --- freechat-client/src/request.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/freechat-client/src/request.js b/freechat-client/src/request.js index c2245d1..4852dfb 100644 --- a/freechat-client/src/request.js +++ b/freechat-client/src/request.js @@ -1,5 +1,6 @@ const got = require('got') const { Response } = require('./response.js') +const fs = require('fs') /** * @@ -15,14 +16,19 @@ const { Response } = require('./response.js') exports.Request = async function (method, domain, port, path, params, body=null) { try { - // TODO: force https since actual servers do not response on port 80 - const url = `http://${domain}:${port}` - let options = { + let url = `https://${domain}:${port}${path}` + const options = { method: method, searchParams: params, responseType: 'json', - throwHttpErrors: false + throwHttpErrors: false, } + + // NOTE: only in dev environments do we use http + if(process.env['DEV_ENV']) { + url = `http://${domain}:${port}${path}` + } + if(body) { options.body = body if(method == 'get') {