Why does PostgREST give me a 404 error when I try ...
# sql
p
Why does PostgREST give me a 404 error when I try to update a record that has a RLS policy that prevents updating? When I satisfy the RLS policy it returns 200
b
I think what's happening here is that after you update or insert a record, Postgrest is doing a select on the record to return data back to you. I've had this problem before when I wanted a user to
INSERT
data but not be able to
SELECT
data (for logging purposes only.)
The solution was to add this as a parameter to my
INSERT
call with the `Supabase JS Client`: {returning: 'minimal'}
The same is probably true for
UPDATE
.
Copy code
const { data, error } = await supabase
    .from('device_log')
    .insert([
      { 
        userid: 'aaa',
        model: 'bbb',
       }
    ],{returning: 'minimal'});
I may be way off base here for your use case, but in general, I've had problems before when I didn't understand that doing an
insert
or
update
also triggered a
select
behind the scenes. Hope this helps.
4 Views