1.5 KiB
1.5 KiB
Environment Configuration
This directory contains environment-specific configuration files for the Angular application.
Files
environment.ts- Development environment configurationenvironment.prod.ts- Production environment configuration
API Configuration
The API base URL is configured in these environment files and accessed through the ApiConfigService.
Development
export const environment = {
production: false,
apiUrl: 'http://localhost:21860/api'
};
Production
export const environment = {
production: true,
apiUrl: 'https://your-production-api.com/api'
};
Usage
Instead of hardcoding API URLs, use the ApiConfigService:
import { ApiConfigService } from '../core/services/api-config.service';
constructor(private apiConfig: ApiConfigService) {}
// Get specific endpoint URLs
const authUrl = this.apiConfig.authUrl; // http://localhost:21860/api/Auth
const usersUrl = this.apiConfig.usersUrl; // http://localhost:21860/api/Users
// Or build custom URLs
const customUrl = this.apiConfig.getApiUrl('CustomEndpoint'); // http://localhost:21860/api/CustomEndpoint
Benefits
- Environment-specific URLs: Different URLs for development, staging, and production
- Centralized configuration: All API URLs managed in one place
- Type safety: TypeScript support for configuration
- Easy maintenance: Change URLs without touching service code
- Build-time optimization: Angular replaces environment variables at build time