mirror of
https://github.com/Mail-0/Zero.git
synced 2026-07-01 08:16:28 +00:00
24 lines
684 B
TypeScript
24 lines
684 B
TypeScript
import { customSessionClient } from 'better-auth/client/plugins';
|
|
import { createAuthClient } from 'better-auth/client';
|
|
import type { Auth } from '@zero/server/auth';
|
|
|
|
const authClient = createAuthClient({
|
|
baseURL: import.meta.env.VITE_PUBLIC_BACKEND_URL,
|
|
fetchOptions: {
|
|
credentials: 'include',
|
|
},
|
|
plugins: [customSessionClient<Auth>()],
|
|
});
|
|
|
|
export const authProxy = {
|
|
api: {
|
|
getSession: async ({ headers }: { headers: Headers }) => {
|
|
const session = await authClient.getSession({
|
|
fetchOptions: { headers, credentials: 'include' },
|
|
});
|
|
if (session.error) throw new Error(session.error.message);
|
|
return session.data;
|
|
},
|
|
},
|
|
};
|