web: prepare for building with external API bases
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
dd9dc7e596
commit
3ab9798f38
|
@ -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(),
|
||||
|
|
|
@ -50,7 +50,7 @@ export function tenant(): Promise<CurrentTenant> {
|
|||
}
|
||||
|
||||
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}`);
|
||||
|
|
Reference in New Issue