Magic Link Type Error

@bekacru Bro i am getting this error :-

POST /api/auth/sign-in/magic-link 500 in 7672ms
[TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}
[TypeError: The "payload" argument must be of type object. Received null] {
code: 'ERR_INVALID_ARG_TYPE'
}

while i am doing magic link authentication using better auth, how can i solve this properly tell me:

auth.ts :-

import { betterAuth } from "better-auth";
import { prisma } from "./db";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { magicLink } from "better-auth/plugins";
import { sendEmailWithMagicLink } from "@/utils/SendEmail";

export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
session: {
expiresIn: 60 * 60 * 24 * 7,
updateAge: 60 * 60 * 24,
},
plugins: [
magicLink({
sendMagicLink: async ({ email, token, url }, request) => {
console.log("Sending magic link to", email, "with token", token);
await sendEmailWithMagicLink({ email, url });
},
}),
],
});

export type AuthConfig = typeof auth;
export type Session = typeof auth.$Infer.Session;
export type User = {
id: string;
name: string;
email: string;
role: string;
};

route.ts :-

import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";

export const { POST, GET } = toNextJsHandler(auth);

frontend calling :-

const { error } = await authClient.signIn.magicLink({
email,
callbackURL: '/blogs'
})

how can i fix this issue, i am trying to fix this from last night but couldn't find any solution to this.
Was this page helpful?