import DashboardListClient from "@/app/(main)/admin/dashboard/DashboardListClient"; import { cookies } from "next/headers"; /** * 서버에서 초기 대시보드 목록 fetch */ async function getInitialDashboards() { try { // 서버 사이드 전용: 백엔드 API 직접 호출 // 도커 네트워크 내부에서는 서비스 이름 사용, 로컬에서는 127.0.0.1 const backendUrl = process.env.SERVER_API_URL || "http://backend:8080"; // 쿠키에서 authToken 추출 const cookieStore = await cookies(); const authToken = cookieStore.get("authToken")?.value; if (!authToken) { // 토큰이 없으면 빈 데이터 반환 (클라이언트에서 로드) return { dashboards: [], pagination: { total: 0, page: 1, limit: 10 }, }; } const response = await fetch(`${backendUrl}/api/dashboards/my?page=1&limit=10`, { cache: "no-store", // 항상 최신 데이터 headers: { "Content-Type": "application/json", Authorization: `Bearer ${authToken}`, // Authorization 헤더로 전달 }, }); if (!response.ok) { throw new Error(`Failed to fetch dashboards: ${response.status}`); } const data = await response.json(); return { dashboards: data.data || [], pagination: data.pagination || { total: 0, page: 1, limit: 10 }, }; } catch (error) { console.error("Server-side fetch error:", error); // 에러 발생 시 빈 데이터 반환 (클라이언트에서 재시도 가능) return { dashboards: [], pagination: { total: 0, page: 1, limit: 10 }, }; } } /** * 대시보드 관리 페이지 (서버 컴포넌트) * - 페이지 헤더 + 초기 데이터를 서버에서 렌더링 * - 클라이언트 컴포넌트로 초기 데이터 전달 */ export default async function DashboardListPage() { const initialData = await getInitialDashboards(); return (
{/* 페이지 헤더 (서버에서 렌더링) */}

대시보드 관리

대시보드를 생성하고 관리할 수 있습니다

{/* 나머지 컨텐츠 (클라이언트 컴포넌트 + 서버 데이터) */}
); }