WIP
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# Environment Configuration
|
||||
|
||||
This directory contains environment-specific configuration files for the Angular application.
|
||||
|
||||
## Files
|
||||
|
||||
- `environment.ts` - Development environment configuration
|
||||
- `environment.prod.ts` - Production environment configuration
|
||||
|
||||
## API Configuration
|
||||
|
||||
The API base URL is configured in these environment files and accessed through the `ApiConfigService`.
|
||||
|
||||
### Development
|
||||
```typescript
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiUrl: 'http://localhost:21860/api'
|
||||
};
|
||||
```
|
||||
|
||||
### Production
|
||||
```typescript
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiUrl: 'https://your-production-api.com/api'
|
||||
};
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Instead of hardcoding API URLs, use the `ApiConfigService`:
|
||||
|
||||
```typescript
|
||||
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
|
||||
|
||||
1. **Environment-specific URLs**: Different URLs for development, staging, and production
|
||||
2. **Centralized configuration**: All API URLs managed in one place
|
||||
3. **Type safety**: TypeScript support for configuration
|
||||
4. **Easy maintenance**: Change URLs without touching service code
|
||||
5. **Build-time optimization**: Angular replaces environment variables at build time
|
||||
Reference in New Issue
Block a user