import { dev } from '$app/environment'; import { env } from '$env/dynamic/public'; export interface ApiConfig { baseUrl: string; isLocal: boolean; } /** * Get API configuration based on environment */ export function getApiConfig(): ApiConfig { // Check for explicit environment variable first const apiUrl = env.PUBLIC_API_URL; if (apiUrl) { return { baseUrl: apiUrl, isLocal: apiUrl.includes('localhost') || apiUrl.includes('127.0.0.1') }; } // Default behavior: use localhost in dev, production URL in prod if (dev) { return { baseUrl: 'http://localhost:8000', isLocal: true }; } return { baseUrl: 'https://dylanebert-3d-arena-backend.hf.space', isLocal: false }; } /** * Get full API endpoint URL */ export function getApiEndpoint(path: string): string { const config = getApiConfig(); return `${config.baseUrl}${path}`; } /** * Public API endpoints */ export const ApiEndpoints = { PAIR: '/pair', VOTE: '/vote', LEADERBOARD: '/leaderboard', } as const;