How to refresh user session automatically when using @supabase/ssr #30465
Unanswered
dule-kitemetric
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've implemented Supabase Auth in NestJS using @supabase/ssr package, version 0.3.0.
Each request will go through my SupabaseMiddleware before moving to another step of the request's lifecycle.
Problem: When user session is expired, Supabase Auth try to refresh user session (set cookies via response), which sometimes leads to error
[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
(attached image)Cause: Supabase Auth handles refresh session asynchronously. For requests taking little time, controller/service will return response to FE before Supabase Auth has done updating user session cookie (via response)
Question: Is there a way to handle this problem? I want when user session expired, my app automatically refresh session without redirect to login page
Beta Was this translation helpful? Give feedback.
All reactions