Category: Supabase and databases

Supabase RLS: Record counter is different from user list

Read this guide in Polish

The administrator sees many records, the sales representative has a smaller list, but the header suggests the same number for both accounts.

Why is this happening?

The counter from the administrative endpoint can omit security policy while SELECT in the browser works with the employee's JWT.

Step by step solution

1. Specify the number semantics: all company records or just visible for the role? Name it in UI by definition.

2 . For the employee counter, make a request under its permission context.

3 . When counting the administrator, do not send the values available to the administrator only to customers without permission.

4 . Prepare the SELECT and count test for three roles, including records with another maintainer.

5 . Save in the documentation whether the archive, resignations, and blocked leads enter the counter.

How do I check the score?

Each role receives a correct number as defined; the result does not reveal the existence of protected records.

Hidden an item in React does not protect the table. RLS policies and server authorisation remain mandatory.