Environment files
Angular CLI projects include environment files undersrc/environments/. The CLI swaps these files at build time based on the --configuration flag you pass to ng build.
Environment file structure
The default development environment file exports a singleenvironment object:
environment.ts with environment.prod.ts when you build with the production configuration. You can define additional configurations (e.g., staging) in angular.json.
Configuration keys
| Key | Type | Default | Description |
|---|---|---|---|
production | boolean | false | Enables Angular production mode. Disables debug tooling and enables optimizations. |
apiBaseUrl | string | http://localhost:3000/api | Base URL for all Karma LMS REST API calls. All HTTP service requests are prefixed with this value. |
authDomain | string | '' | Your identity provider domain. Used to construct OAuth/SAML redirect URLs and token validation endpoints. |
appTitle | string | 'Karma LMS' | Application title displayed in the browser tab and the top navigation bar. |
Building for different environments
Pass--configuration to ng build to select the target environment file:
- Production
- Staging
- Development
staging configuration, add a fileReplacements entry to angular.json:
angular.json (excerpt)
src/environments/environment.staging.ts with your staging values.
Serving locally
To run the development server with a specific environment:ng serve uses the development configuration.
Accessing environment values in code
Import the environment object wherever you need it:app.service.ts
Never commit secrets — passwords, private API keys, or client secrets — to your environment files. These files are checked into version control and are not encrypted. Use a secrets manager or inject values at build time from your CI/CD environment instead.
