SSR Auth / SvelteKit / RLS issue
Hi! I'm trying to set up Auth in my SvelteKit project but can't make RLS work.
I followed the instructions to instantiate Supabase client in hooks and layout.ts. Sign up, Log in and Log out seem to work fine.
I can see cookies with JWT tokens created, active sessions in auth.sessions, the session is active on the server (locals.getSession()), etc.
One thing I noticed is that when I try to check JWT token on jwt.io, it correctly displays sub and aud ('authenticated') but also it says 'Invalid Signature' at the bottom - not sure why?
I've set up RLS policies to restrict select with USING (auth.uid() = user_id).
Then I load data from my +page.server.ts file.
getRecords is defined as following (I use pg function to select data)
Not sure how to troubleshoot it either. Seems like I'm missing something obvious but not sure what.
I followed the instructions to instantiate Supabase client in hooks and layout.ts. Sign up, Log in and Log out seem to work fine.
I can see cookies with JWT tokens created, active sessions in auth.sessions, the session is active on the server (locals.getSession()), etc.
One thing I noticed is that when I try to check JWT token on jwt.io, it correctly displays sub and aud ('authenticated') but also it says 'Invalid Signature' at the bottom - not sure why?
I've set up RLS policies to restrict select with USING (auth.uid() = user_id).
Then I load data from my +page.server.ts file.
getRecords is defined as following (I use pg function to select data)
Not sure how to troubleshoot it either. Seems like I'm missing something obvious but not sure what.