changes to pass api_root when client side action
This commit is contained in:
+6
-1
@@ -6,7 +6,12 @@ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|||||||
|
|
||||||
let BASE_URL;
|
let BASE_URL;
|
||||||
const port = parseInt(process.env.PORT, 10) || 3000;
|
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({
|
const agent = new https.Agent({
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ class MyDocument extends Document {
|
|||||||
<Html lang="en">
|
<Html lang="en">
|
||||||
<Head />
|
<Head />
|
||||||
<body>
|
<body>
|
||||||
|
{!process.browser && (
|
||||||
|
<script>
|
||||||
|
window.apiRoot = `{process.env.API_ROOT}`
|
||||||
|
</script>
|
||||||
|
)}
|
||||||
<SkipLink />
|
<SkipLink />
|
||||||
<Main />
|
<Main />
|
||||||
<NextScript />
|
<NextScript />
|
||||||
|
|||||||
Reference in New Issue
Block a user