Overview
Rodando Driver uses Angular’s environment system to manage configuration across different build environments. The app supports separate configurations for development and production builds through environment files.Environment Files
The application uses two primary environment files:src/environments/environment.ts- Development configurationsrc/environments/environment.prod.ts- Production configuration
Angular automatically replaces
environment.ts with environment.prod.ts during production builds using the file replacement feature configured in angular.json.Configuration Variables
Development Environment
The development environment (src/environments/environment.ts) includes comprehensive configuration for local development:
src/environments/environment.ts
Production Environment
The production environment (src/environments/environment.prod.ts) contains minimal configuration:
src/environments/environment.prod.ts
Environment Variables Reference
| Variable | Type | Description |
|---|---|---|
production | boolean | Indicates if the app is running in production mode |
googleMapsApiKey | string | Google Maps API key with Places library enabled |
apiUrl | string | Base URL for API requests |
appAudience | string | Application audience identifier (e.g., ‘driver_app’) |
expectedUserType | string | Expected user type for authentication (e.g., ‘driver’) |
mapbox.accessToken | string | Mapbox access token for alternative map provider |
debug | boolean | Enable/disable debug mode |
debugTags | string[] | Array of debug tag filters |
wsBase | string | WebSocket base URL for real-time connections |
Setting Up Environments
Configure Development Settings
Update
src/environments/environment.ts with your local development configuration:Configure Production Settings
Update
src/environments/environment.prod.ts with your production configuration:Using Environment Variables
Import and use environment variables throughout your application:Example: HTTP Service Configuration
Building for Different Environments
- Development
- Production
Build for development (uses Or run the development server:
environment.ts):Debug Configuration
The development environment includes debug settings:Debug Tags
| Tag | Description |
|---|---|
DA | Driver App general debugging |
HTTP | HTTP request/response logging |
LOC | Location and GPS debugging |
Security Best Practices
Never Commit Secrets
Do not commit sensitive API keys or tokens to version control. Use environment-specific files that are gitignored or environment variables.
Use Different Keys for Environments
Use separate API keys for development and production:
- Development: Restricted test keys with quotas
- Production: Production keys with appropriate restrictions
Rotate Keys Regularly
Regularly rotate API keys and access tokens, especially after team member changes.
Troubleshooting
Wrong Environment Being Used
If the wrong environment file is being used:- Check your build configuration in
angular.json - Verify file replacements are configured correctly
- Clear the build cache:
rm -rf www/ .angular/ - Rebuild:
ng build --configuration=production
Environment Variables Not Updating
- Stop the development server
- Clear Angular cache:
rm -rf .angular/ - Restart:
npm start
Missing Environment Variables
If you encounter errors about missing environment properties:- Ensure both
environment.tsandenvironment.prod.tshave the same property structure - Add any missing properties to both files
- Use TypeScript interfaces to enforce consistency:
Next Steps
Google Maps Setup
Configure Google Maps API key and map options
Capacitor Config
Set up Capacitor for native mobile builds