Refresh Token Not Found / 0.4.0-rc.2 #33008
Replies: 4 comments
-
Hi @hf ! Tagging you here out of desperation :) since I see you respond to a lot of folks stuck in similar situations |
Beta Was this translation helpful? Give feedback.
-
My understanding is that |
Beta Was this translation helpful? Give feedback.
-
Ok folks I figured this out based on this comment's "gotcha". @hf what was happening was that I had some leftover cookies from For anyone else running into this, I created a utility function
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone, due to inactivity on this issue I've moved the issue over to discussions/enhancements. |
Beta Was this translation helpful? Give feedback.
-
Bug report
Keywords
"Refresh Token Not Found", "cookies", "subdomain", "apex domain", "auth", "cookie Options", "cookieOptions"
Describe the bug
TLDR; If user has logged in, a long time ago, they are prompted to login again (
getUser
is null). They login, receive the magic link, are correctly redirected afterverifyOtp
without errors, but the client throwsAuthApiError: Invalid Refresh Token: Refresh Token Not Found
. Now the user is stuck in a login loop.I suspect
cookieOptions
is the cause of the issue since the issue doesn't arise in local development. Only in production.I am using supabase.auth across 2 domains:
app.domain.com
andapi.domain.com
. This is the flow that a user takes:app.domain.com
and enter their email. The client makes a call toapi.domain.com/login
to initiate loginapi.domain.com/login
makes a call tosupabase.auth.signInWithOtp
with user's email and the following emailRedirectToapp.domain.com/api/auth/confirm
app.domain.com/api/auth/confirm
!confirm
route successfully executesauth.verifyOtp
. User is correctly redirected. No errors.AuthApiError: Invalid Refresh Token: Refresh Token Not Found
App --- app.domain.com
This is a Next.js (14.2.3) web app. We do not use server component and everything happens on the client side with the exception of the
confirm
route.app/api/auth/confirm/route.ts
@/utils/supabase/server
useAuthUser
@/utils/supabase
API --- api.domain.com
This is also a Next.js (14.2.3) setup, acting as an API gateway leveraging tRPC
api.domain.com/account/login
../../supabase/server'
ctx.cookies
Steps Taken
Steps to reproduce the behavior, please provide code snippets or a repository:
Refresh token reuse interval
to 100 secondshttps://**.domain.com**
listed under Redirect URLsExpected behavior
Upon login and redirection the refresh token is found and valid, and
getUser
/getSession
return valid results.Screenshots
System information
Beta Was this translation helpful? Give feedback.
All reactions