import { createAuthClient } from "better-auth/client"; // Get base URL from environment or use localhost as fallback const getBaseURL = () => { if (typeof window === 'undefined') { return process.env.BETTER_AUTH_URL || "http://localhost:3000"; } // For client-side, use the current origin but allow localhost variations const origin = window.location.origin; if (origin.includes('localhost') || origin.includes('127.0.0.1') || origin.includes('0.0.0.0')) { return "http://localhost:3000"; // Normalize to localhost for Better Auth } return origin; }; export const authClient = createAuthClient({ baseURL: getBaseURL(), });