Realtime subscription happens before session
I am making a chat application with sveltekit and I have a component
Everything was working fine until I enabled RLS where only authenticated users can insert to the chat_messages table.
It started to work very inconsistently and I noticed that in my
I use supabase auth and I copy and pasted the code from here: https://supabase.com/docs/guides/auth/server-side/creating-a-client?framework=sveltekit&environment=hooks
I am super confused, how does the
Here's some code if it helps
<RealtimeSubscription/>, that subscribes to the db changes. Everything was working fine until I enabled RLS where only authenticated users can insert to the chat_messages table.
It started to work very inconsistently and I noticed that in my
realtime schema on the subscription table the claims_role is sometimes anon. I believe this is because the realtime sub is happening before some auth stuff? I use supabase auth and I copy and pasted the code from here: https://supabase.com/docs/guides/auth/server-side/creating-a-client?framework=sveltekit&environment=hooks
I am super confused, how does the
supabaseClient sometimes know the user is authenticated but sometimes don't? Here's some code if it helps
supabase.tsRealtimeSubscription.svelte