fix(mana-auth): set callbackURL instead of redirectTo for email verification redirect

Better Auth uses callbackURL to determine the post-verification redirect target.
Setting only redirectTo left callbackURL=/ which resolved to auth.mana.how/ (404).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-31 18:34:56 +02:00
parent 8e1601076f
commit d23ef52839

View file

@ -188,11 +188,12 @@ export function createBetterAuth(databaseUrl: string) {
// during the verification process in the passthrough controller
const sourceAppUrl = sourceAppStore.get(user.email);
// Modify verification URL to include redirectTo parameter
// Modify verification URL: set callbackURL so Better Auth redirects
// back to the source app after email verification
let verificationUrl = url;
if (sourceAppUrl) {
const urlObj = new URL(url);
urlObj.searchParams.set('redirectTo', sourceAppUrl);
urlObj.searchParams.set('callbackURL', sourceAppUrl);
verificationUrl = urlObj.toString();
}