Insert row into RLS enabled table from edge function using new keys
Using the new types of assymetric keys, could anyone share an example of a react / vite function that would retrieve the necessary information to be allowed to insert a row into a table?
It would also be great to confirm how the able needs to be set up in RLS for this to work. Thanks!
9 Replies
RLS does not change with the new keys.
I'm not moving from a functioning version of the old keys to the new keys and I'm having trouble getting the old keys to work, so I thought I might as well try to get it to work with the new keys.
So, I'm still hoping for help to have an edge function insert a row in a table without any errors.
What errors are you getting?
What is your createClient to insert call code?
How is your function being called?
There is not much info yet on dealing with this in edge functions but RLS and user JWT's should work the same. It is the service_role/anon key that are handled differently now in edge it seems.
https://github.com/orgs/supabase/discussions/29289#discussioncomment-13761868
https://github.com/orgs/supabase/discussions/29260 has a couple of notes on edge functions in first big post.
I'm using Tempo with Vite for my app. I'm trying to add a row to a supabase table and I haven't been able to figure out why I'm still getting 500 errors with 'can't insert row'. It seems like there are a lot of things that can get in the way.
Maybe I misunderstood as you said edge function I assumed Supabase Edge functions. Are you doing your own functions?
I'm not familar with Tempo and there are no user posts here with that in them.
Tempo is, for better or for worse, creating supabase edge functions and seems to do an ok job so far, other than figuring out RLS issues
Not enough info to help. Your not showing any code.
Are you passing an authentication header with a user jwt to the edge function? If so then it should work as per the guides.
What are your policies? What is your insert call?
Here are my policies. I'm pretty sure they can be improved, but do they suggest that the issue is whether service_role is really being used?
If service role is being used then RLS policies don't matter. They are not looked at.