Supabase · sdk · fg-0199

Supabase client created with the service role key still gets RLS errors or empty results

If you see new row violates row-level security policy from a client built with the service_role or sb_secret key, the cause and the fix for Supabase are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
new row violates row-level security policy from a client built with the service_role or sb_secret keyAdmin queries return [] in a Next.js server action using createServerClientService role client stops bypassing RLS after calling signUp or signInWithPassword on it
Cause
RLS is decided by the Authorization header, not the apikey header. SSR clients copy the user session from cookies into that header, and auth calls on a shared client replace it with the user's JWT.
Fix
Build a separate admin client with plain createClient, no cookies, and session persistence off. Create users with auth.admin.createUser rather than signUp on that client.
Apply
import { createClient } from '@supabase/supabase-js'; export const admin = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SECRET_KEY, { auth: { persistSession: false, autoRefreshToken: false }, });
Affected
supabase-js 2.x and @supabase/ssr; legacy service_role keys and new secret keys alike
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun