ui-nyla/config/config.ts
ValueOn AG 0331a59da3
All checks were successful
Deploy Nyla Frontend to Production / deploy (push) Successful in 46s
config fix
2026-05-25 17:35:52 +02:00

22 lines
807 B
TypeScript

/**
* Configuration — reads mandatory env vars set by .env (copied from config/env-*.env by CI).
*
* NO silent fallbacks for critical values.
* If VITE_API_BASE_URL is missing the app fails loudly at startup.
*
* Vite replaces import.meta.env.VITE_* statically at build time.
* Dynamic access via import.meta.env[key] does NOT work in production builds.
* Therefore each variable must be accessed with its literal property name.
*/
const _apiBaseUrl: string = import.meta.env.VITE_API_BASE_URL;
if (!_apiBaseUrl) {
throw new Error(
'Missing required env variable: VITE_API_BASE_URL. Ensure .env is present (cp config/env-<env>.env .env).'
);
}
export const getApiBaseUrl = (): string => _apiBaseUrl;
export const getAppName = (): string => import.meta.env.VITE_APP_NAME || 'PowerOn';