"use client";
import { useEffect, useState } from "react";
function useOrigin() {
  const [mounted, setMounted] = useState(false);
  const [origin, setOrigin] = useState("");
  useEffect(() => {
    setMounted(true);
    if (typeof window !== "undefined") {
      try {
        const loc = window.location;
        if (loc && loc.origin) {
          setOrigin(loc.origin);
        }
      } catch {
      }
    }
  }, []);
  if (!mounted || !origin) {
    return process.env.NEXT_PUBLIC_APP_URL || "http://localhost:5173";
  }
  return origin;
}
export {
  useOrigin
};
