/** * RAG 챗봇 클라이언트 - 공통 기능 */ document.addEventListener('DOMContentLoaded', function() { // API 기본 URL const API_BASE_URL = window.location.origin; // 상태 확인 함수 async function checkApiStatus() { try { const response = await fetch(`${API_BASE_URL}/api/status`); const data = await response.json(); if (data.ready) { // API 서버 준비 완료 console.log('API 서버 준비 완료'); // 로딩 페이지에서 왔다면 홈으로 리디렉션 if (window.location.pathname === '/loading') { window.location.href = '/'; } return true; } else { // API 서버 준비 중 console.log('API 서버 초기화 중...'); // 로딩 페이지가 아니면 로딩 페이지로 리디렉션 if (window.location.pathname !== '/loading') { window.location.href = '/loading'; } return false; } } catch (err) { console.error('API 서버 상태 확인 실패:', err); // 연결 오류 시 처리 const statusDisplay = document.getElementById('apiStatusDisplay'); if (statusDisplay) { statusDisplay.innerHTML = `