Skip to content

Commit

Permalink
Chore: update edge function example (supabase#32808)
Browse files Browse the repository at this point in the history
Update auth.mdx
  • Loading branch information
mansueli authored Jan 15, 2025
1 parent 592af2f commit 3e94bc4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/docs/content/guides/functions/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ import { createClient } from 'jsr:@supabase/supabase-js@2'

Deno.serve(async (req: Request) => {

const authHeader = req.headers.get('Authorization')!
const supabaseClient = createClient(
Deno.env.get('SUPABASE_URL') ?? '',
Deno.env.get('SUPABASE_ANON_KEY') ?? '',
{ global: { headers: { Authorization: authHeader } } }
)
);

// Get the session or user object
const authHeader = req.headers.get('Authorization')!;
const token = authHeader.replace('Bearer ', '');
const { data } = await supabaseClient.auth.getUser(token);

})
```
Expand Down

0 comments on commit 3e94bc4

Please sign in to comment.