update
This commit is contained in:
46
frontEnd/lib/config/api.ts
Normal file
46
frontEnd/lib/config/api.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* API Configuration
|
||||
* Centralized configuration for API endpoints
|
||||
*
|
||||
* In Development: Calls backend directly at http://localhost:8000
|
||||
* In Production: Uses Next.js rewrites/nginx proxy at /api (internal network only)
|
||||
*/
|
||||
|
||||
// Production: Use relative URLs (nginx proxy)
|
||||
// Development: Use full backend URL
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
export const API_BASE_URL = isProduction
|
||||
? '' // Use relative URLs in production (proxied by nginx)
|
||||
: (process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000');
|
||||
|
||||
export const API_CONFIG = {
|
||||
// Django API Base URL
|
||||
BASE_URL: API_BASE_URL,
|
||||
|
||||
// Media files URL (for uploaded images, etc.)
|
||||
MEDIA_URL: `${API_BASE_URL}/media`,
|
||||
|
||||
// API Endpoints
|
||||
ENDPOINTS: {
|
||||
CONTACT: '/api/contact',
|
||||
CONTACT_SUBMISSIONS: '/api/contact/submissions',
|
||||
CONTACT_STATS: '/api/contact/submissions/stats',
|
||||
CONTACT_RECENT: '/api/contact/submissions/recent',
|
||||
SERVICES: '/api/services',
|
||||
SERVICES_FEATURED: '/api/services/featured',
|
||||
SERVICES_SEARCH: '/api/services/search',
|
||||
SERVICES_STATS: '/api/services/stats',
|
||||
SERVICES_CATEGORIES: '/api/services/categories',
|
||||
},
|
||||
|
||||
// Request timeout (in milliseconds)
|
||||
TIMEOUT: 10000,
|
||||
|
||||
// Retry configuration
|
||||
RETRY: {
|
||||
ATTEMPTS: 3,
|
||||
DELAY: 1000,
|
||||
}
|
||||
} as const;
|
||||
|
||||
export default API_CONFIG;
|
||||
Reference in New Issue
Block a user