import { headers } from "next/headers"; /** 服务端获取第一个志愿者,用于替换发起人志愿者卡片。调用内部 API(API 优先走 salonapi 后端) */ export async function getVolunteer(): Promise<{ nickname: string; avatar?: string; xiaohongshu_url?: string; } | null> { try { const headersList = await headers(); const host = headersList.get("host") || headersList.get("x-forwarded-host") || "localhost:3002"; const proto = headersList.get("x-forwarded-proto") || (host.includes("localhost") ? "http" : "https"); const base = `${proto}://${host}`; const res = await fetch(`${base}/api/join/volunteers`, { cache: "no-store" }); const data = await res.json(); const v = data?.volunteer; return v && typeof v === "object" && v.nickname ? v : null; } catch { return null; } }