Email verification callback URL

Hello, First thank you for your amazing work on Better-auth. I'm trying to figure out how can I define a callback URL when enabling :
export const auth = betterAuth({
emailAndPassword: {
requireEmailVerification: true
}
})
export const auth = betterAuth({
emailAndPassword: {
requireEmailVerification: true
}
})
Because by default when this option is enabled the verification email is sent automatically on every register with the server callback URL, my issue is that my front is separated from my backend so the redirect is wrong. How could I specifie a callback URL and keep the required email verification ? Best regards
2 Replies
Blingus
Blingus4mo ago
Did you figure this out? Sorry to bump and old thread but I am looking for the same information for anyone else looking for this answer.. you can't directly change the callbackURL for the one triggered by sendOnSignup, but you can parse the URL and manually change the param:
sendVerificationEmail: async ({ user, url }) => {
// change the callbackURL search param in the url variable
const urlObj = new URL(url);
urlObj.searchParams.set('callbackURL', '/dashboard?welcome=true');
url = urlObj.toString();
sendVerificationEmail: async ({ user, url }) => {
// change the callbackURL search param in the url variable
const urlObj = new URL(url);
urlObj.searchParams.set('callbackURL', '/dashboard?welcome=true');
url = urlObj.toString();
Blingus
Blingus4mo ago
GitHub
callbackURL isnt respected · Issue #1367 · better-auth/better-auth
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 redir...

Did you find this page helpful?