How can I set up an admin dashboard with supabase-js querying to bypass RLS stuff?
k
ktosiek
12/23/2021, 8:12 AM
You'll need to use the key from project Settings -> API -> service_role secret
ktosiek
12/23/2021, 8:12 AM
But never use it in browser, this key should only be used with a trusted server-side app.
v
Village
12/23/2021, 3:35 PM
Yes, but how can I fetch data with the library and bypass RLS without exposing that key?
k
ktosiek
12/23/2021, 4:04 PM
You'd need a server-side component that prepares dashboard data.
I don't know what's your architecture, the options I see are:
1. allow admins to see all data they need for dashboards,
2. prepare dedicated "security definer" functions that expose dashboard data (and check that the current user is an admin)