ui-nyla/config/config.ts
ValueOn AG 7eb305f910
Some checks failed
Deploy Nyla Frontend to Integration / deploy (push) Failing after 56s
cp adapted to 2026 poweron
2026-06-09 09:53:38 +02:00

24 lines
864 B
TypeScript

// Copyright (c) 2026 PowerOn AG
// All rights reserved.
/**
* 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';