No cookies set when using the signInEmail method

Hello,
I have configured Better-Auth to connect with email/password.
The information passes correctly to connect the user, the associated data is returned.
However, no cookie is set in the browser, so I can't return anything with getSession...

auth.methods.ts
export const signIn = action.schema(signInSchema).action(async ({ parsedInput: input, ctx }) => {    
    await authentication.api.signInEmail({
        body: {
            email: input.email,
            password: input.password,
            callbackUrl: "/",
            redirect: true, // not working
        }
    }).then((r) => console.log(r));
});


auth-client.ts
import { createAuthClient } from "better-auth/react"
import { env } from "process"

export const authClient = createAuthClient({
    baseURL: env.BETTER_AUTH_URL
})


auth.ts
export const authentication = betterAuth({
    emailAndPassword: {
        enabled: true
    },
    database: prismaAdapter(prisma, { provider: "sqlite" }),
    plugins: [nextCookies()]
});


auth.schema.ts
export const signInSchema = z.object({
    email: z.string().email(),
    password: z.string().min(12)
});


auth.helper.ts
export const authCheck = async () => {    
    const session = await auth.api.getSession({
        headers: await headers()
    }) // return null
    
    if (session?.user) {
        const user = session.user as User;
        return user;
    }

      return null;
};

``
image.png
image.png
image.png
Was this page helpful?