Using Service Role with Supabase in Next.js Backend - Which Approach is Valid? #30739
Unanswered
ganeshrvel
asked this question in
Questions
Replies: 1 comment 8 replies
-
Approach 2 is not possible. The authorization header is what decides if the role is service role. You also cannot use SSR clients with service role as the cookie would replace the default role with a user session. Approach 1 with a supabase-js is the main way. You could potentially create a new Postgres role and mint your own JWT with the jwt secret on the fly with sub UUID and role as |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new to Supabase.
I'm working on a Next.js application with Supabase and want to handle everything through the Next.js backend using
service role
. I'm comparing two approaches and need help understanding which is valid/secure.For both approaches, I start with:
Approach 1: Manual User ID Filtering
Approach 2: Service Role with JWT and RLS
Questions:
auth.uid() = user_id
with service role when sessionToken is passed?I'm trying to understand the proper way to handle this for a production application. Looking for insights on security implications and best practices.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions