47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
/**
|
|
* 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;
|