import { getToken, clearToken } from '@/lib/auth' export async function apiFetch(path: string, options: RequestInit = {}): Promise { const token = getToken() const res = await fetch(path, { cache: 'no-store', ...options, headers: { 'Content-Type': 'application/json', ...(token ? { Authorization: `Bearer ${token}` } : {}), ...(options.headers as Record | undefined ?? {}), }, }) if (res.status === 401) { clearToken() window.location.href = '/login' } return res }