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) {