deckhearth/src/config/api.ts

27 lines
698 B
TypeScript
Raw Normal View History

// API Configuration for All-Vercel Setup
const API_CONFIG = {
development: {
baseURL: 'http://localhost:3000/api/v1', // Local Vercel dev server
},
production: {
baseURL: '/api/v1', // Relative URL for deployed Vercel functions
}
};
const environment = process.env.NODE_ENV as 'development' | 'production';
export const API_BASE_URL = API_CONFIG[environment].baseURL;
// Helper function to build full API URLs
export const buildApiUrl = (endpoint: string) => {
return `${API_BASE_URL}${endpoint.startsWith('/') ? endpoint : `/${endpoint}`}`;
};
// Export for use in services
const apiConfig = {
baseURL: API_BASE_URL,
buildUrl: buildApiUrl,
};
export default apiConfig;