Next Js 14 RLS only for authenticated user not working

I was following through @jonmeyers videos up to https://egghead.io/lessons/next-js-restrict-access-to-authenticated-users-with-supabase-rls-policies .

Before I applied the user.id = auth.uid() expression check in my policy, I just tried to enabling the RLS and refreshed my localhost. Unexpectedly, my data is still visible to all users.

Tried setting the expression check to true and still the same thing but when i tried false instead, it worked as expected (only unauthenticated users can see). That was the exact opposite of what my project needs.

I followed through the video from start up to the RLS section carefully and the auth-helpers using Google provider is working just fine. Sessions are stored in cookies but I am wondering why only the false logic is working and not the true.

I don't think this because my project is built using Next JS 14. Is it my middleware.ts? or I need to manually set conditions if(sessions) to return those data in my page.tsx from getSession(). I tried clearing caches but issues still remain

Hopefully anyone can help me resolve this.
Thank you in advance.
image.png
image.png
image.png
egghead
expert led courses for front-end web developers and teams that want to level up through straightforward and concise lessons on the most useful tools available.
Was this page helpful?