export const getSession = cache(async (): Promise<Session | null> => {
try {
const { data, error } = await authClient.getSession({
fetchOptions: {
headers: await headers(),
},
});
if (error || !data) {
return null;
}
return data as Session;
}
catch (error) {
console.error("Error fetching session:", error);
return null;
}
});
export async function verifySession() {
const session = await getSession();
return {
isAuthenticated: !!session,
session,
user: session?.user || null,
};
}
export const getSession = cache(async (): Promise<Session | null> => {
try {
const { data, error } = await authClient.getSession({
fetchOptions: {
headers: await headers(),
},
});
if (error || !data) {
return null;
}
return data as Session;
}
catch (error) {
console.error("Error fetching session:", error);
return null;
}
});
export async function verifySession() {
const session = await getSession();
return {
isAuthenticated: !!session,
session,
user: session?.user || null,
};
}