import { cookies } from "next/headers"; import { API_BASE } from "./api"; // เรียกจาก Server Component/SSR เพื่อตรวจ session จริง export async function getSession() { const cookieStore = cookies(); const cookie = cookieStore.toString(); const res = await fetch(`${API_BASE}/auth/me`, { headers: { cookie }, credentials: "include", cache: "no-store", next: { revalidate: 0 }, }); if (!res.ok) return null; const data = await res.json(); return data?.user ? data : null; }