Tarun kumar
Tarun kumar
BABetter Auth
Created by Tarun kumar on 2/25/2025 in #help
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.
3 replies
BABetter Auth
Created by Tarun kumar on 2/7/2025 in #help
Issue with Google Auth
I am setting up thing as they are in docs but i am getting error when i am doing signup or signin using google i am not able to solve it, help me with this please :- const handleGoogleSignIn = async () => { try { const data = await authClient.signIn.social({ provider: "google" }) if (data.error) { throw new Error(data.error.message); } } catch (error: unknown) { console.error("Error while loggingin through Google", error); toast({ title: "Error", description: (error as Error).message || "An error occurred during sign-up.", variant: "destructive", }); } }; socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, } }, in auth.ts POST /api/auth/sign-in/social?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fsign-in 400 in 341ms getting this how to fix help me
49 replies