Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions client/app/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ const getConfig = (): Config => {
};

let apiBaseUrl = getGlobalValue('VITE_API_BASE_URL');
const apiStart = getGlobalValue('VITE_API_START') || 'api';
const apiVersionOnly = getGlobalValue('VITE_API_VERSION_ONLY') || 'v1';
const apiVersion = `/${apiStart}/${apiVersionOnly}`;
const configuredApiVersion = getGlobalValue('VITE_API_VERSION') ||
`/${getGlobalValue('VITE_API_START') || 'api'}/${getGlobalValue('VITE_API_VERSION_ONLY') || 'v1'}`;
const apiVersion = `/${configuredApiVersion.replace(/^\/|\/$/g, '')}`;
const versionSeparator = apiVersion.lastIndexOf('/');
const apiStart = apiVersion.slice(1, versionSeparator);
const apiVersionOnly = apiVersion.slice(versionSeparator + 1);
const appName = getGlobalValue('VITE_APP_NAME');
const env = getGlobalValue('VITE_NODE_ENV');
const enableLogging = getGlobalValue('VITE_ENABLE_LOGGING') === 'true';
Expand Down Expand Up @@ -151,4 +154,4 @@ export const API_ENDPOINTS = {
},
HEALTH: '/health',
INFO: '/info',
} as const;
} as const;
14 changes: 11 additions & 3 deletions client/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

CONFIG_PATH="/app/dist/config.js"

# Keep the full API path and its legacy components in sync.
api_version="${VITE_API_VERSION:-/${VITE_API_START:-api}/${VITE_API_VERSION_ONLY:-v1}}"
api_version="/${api_version#/}"
api_version="${api_version%/}"
api_start="${api_version%/*}"
api_start="${api_start#/}"
api_version_only="${api_version##*/}"

echo "Generating runtime config.js from environment variables..."

cat > "$CONFIG_PATH" << EOF
Expand All @@ -15,9 +23,9 @@ window.VITE_API_BASE_URL = "${VITE_API_BASE_URL:-//localhost:8000}";
window.VITE_KEYCLOAK_URL = "${VITE_KEYCLOAK_URL:-}";
window.VITE_KEYCLOAK_CLIENT_ID = "${VITE_KEYCLOAK_CLIENT_ID:-}";
window.VITE_KEYCLOAK_REALM = "${VITE_KEYCLOAK_REALM:-}";
window.VITE_API_START = "${VITE_API_START:-api}";
window.VITE_API_VERSION_ONLY = "${VITE_API_VERSION_ONLY:-v1}";
window.VITE_API_VERSION = "/${VITE_API_START:-api}/${VITE_API_VERSION_ONLY:-v1}";
window.VITE_API_START = "${api_start}";
window.VITE_API_VERSION_ONLY = "${api_version_only}";
window.VITE_API_VERSION = "${api_version}";
window.VITE_APP_NAME = "${VITE_APP_NAME:-KAI Flow}";
window.VITE_NODE_ENV = "${VITE_NODE_ENV:-production}";
window.VITE_ENABLE_LOGGING = "${VITE_ENABLE_LOGGING:-false}";
Expand Down
Loading