craftzcode
Explore posts from serversError using prefetch query with TanStack Query
@coder2000 we have the same problem I just posted now, have you already find a solution for this problem?
https://discord.com/channels/867764511159091230/1360887109119905923/1360887109119905923
10 replies
BABetter Auth
•Created by craftzcode on 4/11/2025 in #help
Problem When Updating the User in the Session
can we solve this by calling the
refetch()
of authClient.useSession
?8 replies
BABetter Auth
•Created by craftzcode on 4/11/2025 in #help
Problem When Updating the User in the Session
so the best thing to do is to use
authClient.updateUser
? instead of updating the user direct on the db instance?8 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
I just confused by the documentation on
Email
the verifyEmail
has callbackURL
when triggering the manual verify email38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
oh I see 😂 it's coming from the callbackURL, so when calling the manual verifyEmail I don't need to pass the callbackURL anymore
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
but in the network tab it said 302? or because of the callbackURL?
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?

38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
I tried to access the error from onError but I didn't get the error even the toke has expired
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
it's not returning as 401, it's returning as 200 that's why I can't handle the error
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
I think this is a bad DX 🤔 it's better to return an error instead of status 200 even if there's a query params for error
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
@Ping @bekacru I can't get the error on
authClient.verifyEmail
even I use router.refresh()
the url
is not changing, is not passing the query params of error.
I'm using a custom url on sendEmailVerification
like this:
Instead the user click the email verification direct to http://localhost:3000/api/auth/verify-email?token
, on this custom url the user will redirect to the custom page to verify manually using authClient.verifyEmail
button.38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
And why does
resetPassword
return an error in onError
when verifyEmail
has the same function to handle token validation? Why is it that for verifyEmail
you don’t return the error in onError
—if you are considering mobile apps and desktop apps.
Also, does the flow for callbackURL
or redirectTo
only work when you directly call api/auth/reset-password
or api/auth/verify-email
? Because that’s what I noticed: when I use the URL from the auth instance itself, the callbackURL
and redirectTo
work; but when I create a custom URL to handle token validation on a custom page and then manually call authClient.resetPassword
or authClient.verifyEmail
, the callbackURL
or redirectTo
don’t work.38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
@bekacru so it's okay that I will use
router.push
or router.refresh
so the error query params will pass on the url?38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
I see, I didn't think about that this is also for multiplatform 😅
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
@Ping @bekacru
You should just make your email verification flow similar to your reset password flow.
In reset password, the error is caught in
onError
when you manually call authClient.resetPassword
.
Unlike the manual call to authClient.verifyEmail
, the HTTP status is still success even if there’s an error in token validation.
For me, I find it a bit challenging to handle the error regarding the query params in manual verify email; it also doesn’t redirect even if there’s a callbackURL
, so the query params never get passed.
That’s why I prefer handling the error in reset password — it doesn’t need a redirect or query params. The error is immediately caught in onError
and it makes it easier to customize the page.38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
how about the error? it's not passing the query params at all, or it will pass now if I use router.push on the
onSuccess
38 replies
BABetter Auth
•Created by craftzcode on 4/8/2025 in #help
Is there an expiration of the email verification token?
@Ping @bekacru
This is what I did to see where the problem is.
First, I tried visiting the default URL of
sendVerificationEmail
in the auth.ts
, which is this:
http://localhost:3000/api/auth/verify-email?token=[TOKEN]&callbackURL=/verify-email
.
When I verify my email directly through this URL, the callbackURL
works; it redirects me to that route whether or not the query parameters are present.
But when I use the manual authClient.verifyEmail
on the client side, the redirect for callbackURL
does not work. It sends a request in the network tab, but it does not redirect.38 replies