Merged PR 376: added api root for client side actions

Related work items: #5231
This commit is contained in:
Robert Bond
2021-07-21 14:21:13 +00:00
2 changed files with 11 additions and 1 deletions
+6 -1
View File
@@ -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,
+5
View File
@@ -23,6 +23,11 @@ class MyDocument extends Document {
<Html lang="en">
<Head />
<body>
{!process.browser && (
<script>
window.apiRoot = `{process.env.API_ROOT}`
</script>
)}
<SkipLink />
<Main />
<NextScript />