/** * API Service * cloud-instances-api 워커 호출 */ // API 설정 (프록시 사용 - /api/* 경로) export const API_CONFIG = { baseUrl: '/api', // Cloudflare Pages Functions 프록시 사용 apiKey: null, // 프록시에서 처리 timeout: 10000 }; /** * API 서비스 객체 */ export const ApiService = { /** * API 요청 헬퍼 */ async request(endpoint, options = {}) { const url = `${API_CONFIG.baseUrl}${endpoint}`; const headers = { 'Content-Type': 'application/json', ...(API_CONFIG.apiKey && { 'X-API-Key': API_CONFIG.apiKey }), ...options.headers }; try { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), API_CONFIG.timeout); const response = await fetch(url, { ...options, headers, signal: controller.signal }); clearTimeout(timeoutId); if (!response.ok) { const error = await response.json().catch(() => ({ message: response.statusText })); throw new Error(error.message || `HTTP ${response.status}`); } return await response.json(); } catch (error) { if (error.name === 'AbortError') { throw new Error('요청 시간이 초과되었습니다.'); } throw error; } } // Removed: health(), getInstances(), recommend(), sync() // These methods referenced deleted API functions (health.ts, instances.ts, recommend.ts) };