The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: use setAuth instead.
thorwebdevdc5fef24a06c
diff --git a/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts b/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.tsindex 1fcfdb4603e..f11a50e63e6 100644--- a/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts+++ b/examples/edge-functions/supabase/functions/select-from-table-with-auth-rls/index.ts@@ -5,18 +5,19 @@import { serve } from 'https://deno.land/[email protected]/http/server.ts'import { createClient } from 'https://esm.sh/@supabase/supabase-js@^1.33.2'+const supabase = createClient(+ // Supabase API URL - env var exported by default when deployed.+ Deno.env.get('SUPABASE_URL') ?? '',+ // Supabase API ANON KEY - env var exported by default when deployed.+ Deno.env.get('SUPABASE_ANON_KEY') ?? ''+)+console.log(`Function "select-from-table-with-auth-rls" up and running!`)serve(async (req: Request) => {- const supabase = createClient(- // Supabase API URL - env var exported by default when deployed.- Deno.env.get('SUPABASE_URL') ?? '',- // Supabase API ANON KEY - env var exported by default when deployed.- Deno.env.get('SUPABASE_ANON_KEY') ?? '',- // Create client with Auth context of the user that called the function.- // This way your row-level-security (RLS) policies are applied.- { headers: { Authorization: req.headers.get('Authorization') ?? '' } }- )+ // Set the Auth context of the user that called the function.+ // This way your row-level-security (RLS) policies are applied.+ supabase.auth.setAuth(req.headers.get('Authorization')!.split('Bearer ')[1])const { data, error } = await supabase.from('users').select('*')console.log({ data, error })