import { headers } from "next/headers";

/**
 * When browsing via LAN path preview `/studio/{slug}/...`, public site links
 * must be prefixed. On real tenant hosts (`{slug}.localhost`) this is empty.
 */
export async function getStudioPathPrefix(): Promise<string> {
  const h = await headers();
  const raw = h.get("x-archi-studio-base")?.trim() ?? "";
  if (!raw) return "";
  return raw.replace(/\/$/, "");
}
