S
Supabase2mo ago
Light

Why am I getting this error while also getting the data?

I'm trying to see if a user is logged in, but I'm not sure why the error object is not empty
No description
12 Replies
garyaustin
garyaustin2mo ago
You should show what call you are making.
Light
LightOP2mo ago
const { data: { user } } = await supabase.auth.getUser() This is what I'm trying to do AuthSessionMissingError: Auth session missing! What is throwing me off is that the header has no issue showing me my name and the logout button
Light
LightOP2mo ago
No description
Light
LightOP2mo ago
So I'm not sure what I'm doing wrong Any ideas would be really appreciated!
garyaustin
garyaustin2mo ago
Probably should also say your environment. Probably going to need someone more familiar with next.js or SSR if that is what you are using. Are you saying the user object has data? The error is saying there is no access_token (session) and user should be null I believe.
Light
LightOP2mo ago
Disabling RLS seems to have resolved the issue, so i've been trying to enable it and learn how to write policies for it to see if that fixes it. Not sure why it didn't give me an error saying it was an RLS issue. Is that by design for security?
garyaustin
garyaustin2mo ago
Not meeting RLS policies will not error for selects, updates and deletes for security reasons. It does error for inserts.
Light
LightOP2mo ago
Got it Any recommendations for how to best learn policies?
garyaustin
garyaustin2mo ago
This is about all Supabase offers: https://supabase.com/docs/guides/database/postgres/row-level-security There maybe more from users on the web as far as blogs/guides.
Row Level Security | Supabase Docs
Secure your data using Postgres Row Level Security.
Light
LightOP2mo ago
Goit it! Thank you so so much If you don't mind me asking. I'm trying to add a button that deletes and event. I'd like that to also delete any data that event had (including all the rows in the order table that relate to this event). I already have them setup with forgien keys, but I don't know where in the menus I'd check that if an event is deleted, all related data from other tables is also deleted I can't seem to add things to the table, but I think the policies should be right.
Light
LightOP2mo ago
For testing, I just wanted to make it so anyone can add something to the table. this is the policy, but I'm still having issues. Disabling RLS fixed the issue, so I'm assuming one of my policies are bad but I'm not sure how
No description
garyaustin
garyaustin2mo ago
Insert will also need a select policy if you are returning data. As far as deleting all related things. If you have a foreign key you want to add a Cascade Delete option to the foreign key definition.

Did you find this page helpful?