[GH-ISSUE #1367] callbackURL isnt respected #26035

Closed
opened 2026-04-17 16:25:23 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @blurskye on GitHub (Feb 6, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1367

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

the callbackURL property isnt respected, i always get callback to /, please fix it

Current vs. Expected behavior

it will redirect to specified url, in this case /chat

What version of Better Auth are you using?

1.1.16

Provide environment information

arch linux

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

import { betterAuth } from "better-auth";

import { PrismaClient } from "@prisma/client";
import { prismaAdapter } from "better-auth/adapters/prisma";
import sendMail from "$lib/utils/sendMail";

const prisma = new PrismaClient();


export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "sqlite"
  }),
  socialProviders: {
  },
  emailAndPassword: {
    enabled: true,
    requireEmailVerification: true,
    sendResetPassword: async ({ user, url }) => {
      await sendMail(
        user.email,
        "Reset your password",
        `Click this link to reset your password: ${url}`
      );
    }
  },
  emailVerification: {
    sendOnSignUp: true,
    autoSignInAfterVerification: true,
    callbackURL: "/chat",
    sendVerificationEmail: async ({ user, url }) => {
      await sendMail(
        user.email,
        "Verify your email address",
        `Welcome! Please verify your email by clicking this link: ${url}`
      );
    }
  }
});
Originally created by @blurskye on GitHub (Feb 6, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1367 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce the callbackURL property isnt respected, i always get callback to /, please fix it ### Current vs. Expected behavior it will redirect to specified url, in this case /chat ### What version of Better Auth are you using? 1.1.16 ### Provide environment information ```bash arch linux ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { PrismaClient } from "@prisma/client"; import { prismaAdapter } from "better-auth/adapters/prisma"; import sendMail from "$lib/utils/sendMail"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "sqlite" }), socialProviders: { }, emailAndPassword: { enabled: true, requireEmailVerification: true, sendResetPassword: async ({ user, url }) => { await sendMail( user.email, "Reset your password", `Click this link to reset your password: ${url}` ); } }, emailVerification: { sendOnSignUp: true, autoSignInAfterVerification: true, callbackURL: "/chat", sendVerificationEmail: async ({ user, url }) => { await sendMail( user.email, "Verify your email address", `Welcome! Please verify your email by clicking this link: ${url}` ); } } }); ```
GiteaMirror added the lockedbug labels 2026-04-17 16:25:24 -05:00
Author
Owner

@Bekacru commented on GitHub (Feb 6, 2025):

callback url isn't meant to be passed in the auth config like this. this isn't supported API. use

await authClient.signUp.email({
 callbackURL: '/chat' //this will be used to redirect back after email verification
})

you can also change the callback url query param on the url passed to sendVerificationEmail callback

<!-- gh-comment-id:2639078147 --> @Bekacru commented on GitHub (Feb 6, 2025): callback url isn't meant to be passed in the auth config like this. this isn't supported API. use ```ts await authClient.signUp.email({ callbackURL: '/chat' //this will be used to redirect back after email verification }) ``` you can also change the callback url query param on the url passed to `sendVerificationEmail` callback
Author
Owner

@blurskye commented on GitHub (Feb 6, 2025):

oh yea, right my bad

<!-- gh-comment-id:2639093342 --> @blurskye commented on GitHub (Feb 6, 2025): oh yea, right my bad
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26035