import { HeaderData, HeaderMenuItem } from '@/types/header'; const CMS_API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001'; export async function fetchHeaderData(): Promise { const res = await fetch(`${CMS_API_URL}/api/header`, { next: { revalidate: 60 }, }); if (!res.ok) { throw new Error(`Failed to fetch header: ${res.status}`); } const json = await res.json(); if (!json.success) { throw new Error(json.message || 'Header API error'); } return json.data as HeaderData; } export async function fetchHeaderMenu(): Promise { const res = await fetch(`${CMS_API_URL}/api/header-menu`, { next: { revalidate: 60 }, }); if (!res.ok) { throw new Error(`Failed to fetch menu: ${res.status}`); } const json = await res.json(); if (!json.success) { throw new Error(json.message || 'Menu API error'); } return json.data as HeaderMenuItem[]; }