From 3ab9798f381aac46e2b4610afd697fbb5b572f06 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 14 Oct 2021 19:45:20 +0200 Subject: [PATCH] web: prepare for building with external API bases Signed-off-by: Jens Langhammer --- web/rollup.config.js | 4 ++++ web/src/api/Config.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/rollup.config.js b/web/rollup.config.js index 7a15f007e..15cf9f03b 100644 --- a/web/rollup.config.js +++ b/web/rollup.config.js @@ -44,6 +44,7 @@ const resources = [ // eslint-disable-next-line no-undef const isProdBuild = process.env.NODE_ENV === "production"; +const apiBasePath = process.env.AK_API_BASE_PATH || ""; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types function manualChunks(id) { if (id.includes("@goauthentik/api")) { @@ -111,6 +112,7 @@ export default [ }), replace({ "process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"), + "process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath), "preventAssignment": true, }), sourcemaps(), @@ -144,6 +146,7 @@ export default [ }), replace({ "process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"), + "process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath), "preventAssignment": true, }), sourcemaps(), @@ -177,6 +180,7 @@ export default [ }), replace({ "process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"), + "process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath), "preventAssignment": true, }), sourcemaps(), diff --git a/web/src/api/Config.ts b/web/src/api/Config.ts index a22432582..d1270964b 100644 --- a/web/src/api/Config.ts +++ b/web/src/api/Config.ts @@ -50,7 +50,7 @@ export function tenant(): Promise { } export const DEFAULT_CONFIG = new Configuration({ - basePath: "/api/v3", + basePath: process.env.AK_API_BASE_PATH + "/api/v3", headers: { "X-CSRFToken": getCookie("authentik_csrf"), }, @@ -61,4 +61,4 @@ export const DEFAULT_CONFIG = new Configuration({ ], }); -console.debug(`authentik(early): version ${VERSION}`); +console.debug(`authentik(early): version ${VERSION}, apiBase ${DEFAULT_CONFIG.basePath}`);