disable magic link redirect and any other redirect
Hello,
I am using better-auth with a Fastify backend, a classic REST api (port 4000) and for the frontend I am using next.js 14 (port 3000).
So I managed to configure better-auth on the backend through a custom Fastify plugin. For the signin I am using the magic link plugin.
I have a signin page on the frontend that just ask for the email then call "authClient.signIn.magicLink".
The user receive an email with a link to the frontend : http://localhost:3000/verify?token=TOKEN
When he arrive to the "verify" page, I can verify the token on the clientSide or serverSide with Next.js and then redirect him to the right page.
The problem I have is that even without using callbackUrl attribute, the route auth/magic-link/verify?token={token} GET does a HTTP redirect which is not what I want. I just need this route to return data or error and then I handle the rest.
What can I do to change its behavior? Do I need to rewrite the plugin? ðŸ«
Maybe I am not using it the right way..
I use better-auth on another project that use next.js ssr / server action (no external backend), it's perfect for that but I feel that when we use an external backend, better-auth is less plug n play 😅
PS: It seems impossible to infer the Typescript type of betterAuth when using inside a fastify plugin (I am obliged use a plugin to get access to my prisma instance, env variables, etc).
0 Replies