From 50998612f18aaebf67cfc3b7fdfbb24ac60e8d64 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 21 Jul 2021 15:20:06 +0100 Subject: [PATCH] changes to pass api_root when client side action --- actions/index.js | 7 ++++++- pages/_document.js | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/actions/index.js b/actions/index.js index 7cc0c2fe..137f0666 100644 --- a/actions/index.js +++ b/actions/index.js @@ -6,7 +6,12 @@ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; let BASE_URL; const port = parseInt(process.env.PORT, 10) || 3000; -BASE_URL = process.env.API_ROOT || `http://localhost:${port}`; + +if (process.browser) { + BASE_URL = window.apiRoot; +} else { + BASE_URL = process.env.API_ROOT || `http://localhost:${port}`; +} const agent = new https.Agent({ rejectUnauthorized: false, diff --git a/pages/_document.js b/pages/_document.js index db5a51a5..237f4716 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -23,6 +23,11 @@ class MyDocument extends Document { + {!process.browser && ( + + )}