serverSupabaseServiceRole


This section assumes you're familiar with Nitro, the server engine powered by Nuxt.

This function is designed to work only in server routes, there is no vue composable equivalent.

It works similary as the serverSupabaseClient but it provides a client with super admin rights that can bypass your Row Level Security.

The client is initialized with the SUPABASE_SERVICE_KEY you must have in your .env file. Checkout the doc if you want to know more about Supabase keys.

Define your server route and just import the serverSupabaseServiceRole from #supabase/server.

server/api/bypass-rls.ts
import { serverSupabaseServiceRole } from '#supabase/server'export default eventHandler(async (event) => {  const client = serverSupabaseServiceRole(event)  const { data } = await client.from('rls-protected-table').select()  return { sensitiveData: data }})

Then call your API route from any vue file:

pages/index.vue
const fetchSensitiveData = async () => {  const { sensitiveData } = await useFetch('/api/bypass-rls')}