That's strange indeed! For me, this still works flawlessly...
Here are some things you can check:
Is the supabase client you use in supabase.auth.api.getUserByCookie the one using the anon key? I'm not sure if this also works with the service key, but I'm using the "regular" Supabase client that I also use in frontend calls.
Is the frontend calling the updateSupabaseCookie method defined in the post? This is necessary to set the cookie and if it's never set, getUserByCookie will indeed return null.
But as the issue suggests, there might still be something wrong on Supabase's side...
Thanks for reading, and hopefully this will resolve your problem!
Best,
Sebastian
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Excellent Article!
However, are you sure this is still up to date? I always receive an empty user object when I call this on server side in getServerSideProps:
const { user } = await supabase.auth.api.getUserByCookie(req);
Looking into the supabase discussions forum this seems to be a known issue:
github.com/supabase/supabase/issue...
Any ideas what I might be doing wrong?
Thanks!
Hi Franz 👋
That's strange indeed! For me, this still works flawlessly...
Here are some things you can check:
supabase
client you use insupabase.auth.api.getUserByCookie
the one using the anon key? I'm not sure if this also works with the service key, but I'm using the "regular" Supabase client that I also use in frontend calls.updateSupabaseCookie
method defined in the post? This is necessary to set the cookie and if it's never set,getUserByCookie
will indeed returnnull
.But as the issue suggests, there might still be something wrong on Supabase's side...
Thanks for reading, and hopefully this will resolve your problem!
Best,
Sebastian