Ditzzy/api
0
1export function getBaseUrl(): string {2 // Check if we're in browser3 if (typeof window !== 'undefined') {4 /*if (window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {5 return process.env.DOMAIN_URL;6 }*/7 return `${(window as any).location.protocol}//${(window as any).location.host}`;8 }9 10 return process.env.NODE_ENV === 'production' 11 ? `${(window as any).location.protocol}//${(window as any).location.host}`12 : 'http://localhost:5000';13}14 15export function getApiUrl(endpoint: string): string {16 const baseUrl = getBaseUrl();17 // Remove leading slash if present to avoid double slashes18 const cleanEndpoint = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;19 return `${baseUrl}/api${cleanEndpoint}`;20}21 22export function getDisplayUrl(): string {23 const baseUrl = getBaseUrl();24 return baseUrl.replace(/^https?:\/\//, '');25}