fix: hide mock in prod

This commit is contained in:
2026-01-14 02:36:27 -05:00
parent d4df1a5104
commit d5f337df80

View File

@@ -52,6 +52,16 @@ function getClient(): AuthClientType {
// Export a Proxy that lazy-loads the client
export const authClient = new Proxy({} as AuthClientType, {
get(_target, prop) {
// Always ensure we're in the browser before accessing the client
if (typeof window === "undefined") {
// During SSR, return safe defaults for common properties
if (prop === "useSession") {
return () => ({ data: null, isPending: false, error: null });
}
return undefined;
}
// In the browser, get the real client
const client = getClient();
const value = client[prop as keyof AuthClientType];
return typeof value === "function" ? value.bind(client) : value;