codenuk_frontend_mine/src/config/backend.ts

26 lines
882 B
TypeScript

/**
* Centralized Backend Configuration
* Single source of truth for all backend URLs
*/
// Main backend URL - change this to update all API calls
export const BACKEND_URL = 'http://localhost:8000';
// export const BACKEND_URL = 'https://backend.codenuk.com';
// Realtime notifications socket URL (Template Manager emits notifications)
// Prefer env override if present; fallback to local Template Manager port
export const SOCKET_URL = process.env.NEXT_PUBLIC_SOCKET_URL || 'http://localhost:8009';
// Export for backward compatibility
export const API_BASE_URL = BACKEND_URL;
// Helper function to get full API endpoint URL
export const getApiUrl = (endpoint: string): string => {
// Remove leading slash if present to avoid double slashes
const cleanEndpoint = endpoint.startsWith('/') ? endpoint.slice(1) : endpoint;
return `${BACKEND_URL}/${cleanEndpoint}`;
};