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_SECRET_KEY(recommended) orSUPABASE_SERVICE_KEY(deprecated) you must have in your.envfile. We recommend using the new JWT signing keys (SUPABASE_SECRET_KEY) as described in the Supabase blog post.
Define your server route and just import the serverSupabaseServiceRole from #supabase/server.
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:
const fetchSensitiveData = async () => {
const { sensitiveData } = await useFetch('/api/bypass-rls')
}