Sometimes auth.uid() yields null
Hi all,
I have plenty of database functions which are called from the frontend via supabase.rpc().
In general this works great and as expected.
In order to secure the requests I make use of the jwt token from the header and by this accessing the userId with auth.uid() in my database function.
For some users this occasionally (and i just cant figure out under which circumstances) yields "null" which then raises a defined exception in my function.
Anyone facing the same problem and could help me out?
How to prevent this from happening?
Does this happen when the session in the user frontend is invalid our expired? Because I thought that the user session gets automatically refreshed.
I am using in the frontend the supabase sdk (supabase/supabase-js = 2.45.4).
I have plenty of database functions which are called from the frontend via supabase.rpc().
In general this works great and as expected.
In order to secure the requests I make use of the jwt token from the header and by this accessing the userId with auth.uid() in my database function.
For some users this occasionally (and i just cant figure out under which circumstances) yields "null" which then raises a defined exception in my function.
Anyone facing the same problem and could help me out?
How to prevent this from happening?
Does this happen when the session in the user frontend is invalid our expired? Because I thought that the user session gets automatically refreshed.
I am using in the frontend the supabase sdk (supabase/supabase-js = 2.45.4).