Row level security is switched on for the table, and no policy lets this request insert this row. Supabase then refuses the insert and returns this error. The table name in your message will differ from the one above.
The usual reasons are a missing insert policy, a policy whose check does not match the row you send, or a request that is not signed in and runs as the anon role.
select policyname, cmd, roles, with_check
from pg_policies
where tablename = 'profiles';const { data: { user } } = await supabase.auth.getUser()
console.log(user?.id)create policy "Users can create their own profile."
on profiles for insert
to authenticated
with check ( (select auth.uid()) = user_id );await supabase.from('profiles').insert({ user_id: user.id, avatar_url })grant insert on table public.profiles to authenticated;Do not fix this by putting the service role key in your front end code, and do not switch row level security off. Supabase says a secret key must never be used in the browser. Either shortcut makes the table readable and writable by anyone who finds your project URL.
Row level security is on for the table and no policy allows this insert. Add an insert policy with a with check clause that matches the row you send, and make sure the request is signed in.
No. Supabase documents the secret key as server-side only. Never ship it in browser code.
The free health check asks ten questions about your app and shows the three fixes to do first. It runs in your browser.
If you would rather have someone read the code, the fixed-price audit is $497 one-time. It covers security and scaling, with a written report ranked by severity.