// lib/http/getServerBaseUrl.ts
import { headers } from "next/headers";

export function getServerBaseUrl(defaultIp: string) {
  const h = headers();
  const proto = h.get("x-forwarded-proto") || "http";
  const host = h.get("host") || defaultIp;
  const port = proto === "https" ? 443 : 80;

  return `${proto}://${host}:${port}`;
}
