OneCX environment variables (runtime configuration)
In OneCX UI applications, "environment variables" are runtime configuration values.
They are loaded at startup.
They have to be provided through a public env.json file, not through OS process environment variables.
They are intended for values that may change after build, such as endpoints, auth settings, or feature flags.
|
The |
What is env.json?
env.json is a JSON object containing key/value pairs.
-
Requirements:
-
The payload must be a JSON object.
-
Keys are strings.
-
Values are expected to be strings (see
Configin@onecx/integration-interface). -
The file must be reachable via HTTP from the running application.
-
-
How to create:
-
src/assets/env.jsonis created in the application (MFE). -
The build serves the file as
assets/env.json.
-
|
|
Config scopes
OneCX UI applications use two runtime config scopes:
-
MFE scope (per microfrontend): AppConfigService
-
Shell scope (shared across multiple microfrontends): ConfigurationService
Global values are shared across apps. Per-app values belong to one app only.
How to influence values
App values (AppConfigService)
AppConfigService loads app-specific values from {baseUrl}/assets/env.json.
These values can be influenced by changing the app’s src/assets/env.json.
Further details are available in AppConfigService.
Shell values (ConfigurationService)
ConfigurationService exposes values loaded by the Shell.
These values are shared with other apps and are configured through the Shell deployment.
Use Shell environment variables exposed by the Shell UI container.
Further details are available in ConfigurationService.
Files configured (Angular)
Shell application:
-
Shell UI container configuration via Dockerfile or deployment manifests (define Shell environment variables)
Microfrontend (MFE):
-
src/assets/env.json(runtime config for that MFE) -
src/environments/environment.ts(build-time defaults) -
src/app/app.module.ts(commonly providesAPP_CONFIG;AppConfigServiceis initialized only where abaseUrlis known)