ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseโ€ข13mo agoโ€ข
3 replies
Malo

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).
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

auth.uid() question
SupabaseSSupabase / help-and-questions
8mo ago
RLS and auth.uid()
SupabaseSSupabase / help-and-questions
4y ago
Title: auth.uid() NULL issue with RLS enabled - Project ID: enzrjbcoxqtnxirlthps
SupabaseSSupabase / help-and-questions
8mo ago
SELECT based on auth.uid()
SupabaseSSupabase / help-and-questions
4y ago