Marked as helpful by the asker
The dashboard runs as postgres, which bypasses RLS, so it will always work there. That's why it feels inconsistent.
Your policy is fine. The usual cause is that the insert doesn't include user_id, so auth.uid() = null is false. Check what your app actually sends:
await supabase.from('orders').insert({ ...order, user_id: user.id })Better: give the column a default so the client can't get it wrong:
alter table orders alter column user_id set default auth.uid();That was it. The form never sent
sam_builds
user_id, Claude Code had dropped it from the payload when it "cleaned up" the insert. Added it back and it works. You can also give the column
hannah_reyes
default auth.uid(). Then the client doesn't have to send it at all, and can't send someone else's. Oh that's nicer, doing that.
sam_builds
createServerClient, check the cookies are actually passed through, otherwiseauth.uid()is null there too. jb_supa