Edge Function cannot insert into table with RLS even using Service Role Key
I am using the Service Role Key inside the Edge Function. Previously I added policies, but even then the insert didn’t work.
9 Replies
If you are truly service_role then RLS will not matter.
So either you are not service_role or you are getting some other error.
"Failed to insert pre_login record: "new row violates row-level security policy for table "pre_login"


have you by any chance moved to jwt signing keys?
What do you do with the client after that point, before the insert?
Im fixed
Sorry for wasting your time.
no worries, would you mind sharing what was the issue just to help people in the future who experience similar issues?
I first use the anon client to authenticate the user and get their ID. After that, I switch to a separate client with the Service Role Key to insert into pre_login. The admin client is only used for the insert, not for login.
makes sense, thanks