Is it possible to set callbackUrl on server-side email sign Ups?
I would like to handle my sign ups on the server side, but I'm struggling to find a proper way to set my callbackUrl in the documentation for the email verification.
Tried it like this, but this doesn't seem to work
How can I set it properly? Or do I have to add it manually in auth.ts?
5 Replies
I also don't seem to get any autocompletion here, which makes it a lot harder to figure out which properties I can define here. Any way to fix that issue too? My tsconfigs also has the
strict
property set to true.I believe callbackURL is a key within body like name, email, password:
https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/api/routes/sign-up.ts#L49
Maybe it's not working
I didn't checked
But I'm using redirect() in onSuccess method
doesn't work either 😦 The lack of server side documentation is really frustrating 😂
I don't think i have that option on the server. Plus I want the redirect to happen after the email verification, not after the sign up.
I have a feeling that this can't be done on the server side yet. I think I will just set the searchParams my self in the
sendVerificationEmail
callback in auth.ts
.
This works
I just wish there was a cleaner way to set the callback url on the server. This feels a bit brute force-yIt's supported on the server-side as well with 'auth.api.sendVerificationEmail' - there is a '/send-verification-email' endpoint used by it that accepts a callbackURL for after the email verification:
https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/api/routes/email-verification.ts#L78