Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
906 B · 24 lines
TypeScript
at main
12345678910111213141516171819202122232425// API configuration for the frontend// Uses environment variables with fallbacks for different environments
// Get the API base URL from environment variable or use defaultconst getApiBaseUrl = (): string => { // In development, default to localhost:8000 where Express server runs // In production, this should be set to the actual backend URL const defaultUrl = 'http://localhost:8000'; // Use REACT_APP_ prefix for Create React App / Parcel compatibility const envUrl = process.env.REACT_APP_API_BASE_URL || process.env.API_BASE_URL; return envUrl || defaultUrl;};
export const API_BASE_URL = getApiBaseUrl();
// Utility function to build full API URLsexport const buildApiUrl = (path: string): string => { // Remove leading slash if present to avoid double slashes const cleanPath = path.startsWith('/') ? path.slice(1) : path; return `${API_BASE_URL}/${cleanPath}`;};