From 944229bae3f59fefac9104ed4c267e59e1ab6780 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 13 Oct 2021 13:22:56 -0700 Subject: [PATCH] Update process env. --- server/accounting/qbo/qbo-callback.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/accounting/qbo/qbo-callback.js b/server/accounting/qbo/qbo-callback.js index ed82c0fcd..d29c7c778 100644 --- a/server/accounting/qbo/qbo-callback.js +++ b/server/accounting/qbo/qbo-callback.js @@ -18,6 +18,16 @@ const oauthClient = new OAuthClient({ logging: true, }); +let url; + +if (process.env.NODE_ENV === "production") { + url = `https://imex.online`; +} else if (process.env.NODE_ENV === "test") { + url = `https://test.imex.online`; +} else { + url = `http://localhost:3000`; +} + exports.default = async (req, res) => { const params = queryString.parse(req.url.split("?").reverse()[0]); try { @@ -28,7 +38,7 @@ exports.default = async (req, res) => { error: authResponse.json, }); res.redirect( - `http://localhost:3000/manage/accounting/qbo?error=${encodeURIComponent( + `${url}:3000/manage/accounting/qbo?error=${encodeURIComponent( JSON.stringify(authResponse.json) )}` ); @@ -46,9 +56,7 @@ exports.default = async (req, res) => { ); res.redirect( - `http://localhost:3000/manage/accounting/qbo?${queryString.stringify( - params - )}` + `${url}:3000/manage/accounting/qbo?${queryString.stringify(params)}` ); } } catch (e) {