Unable to call Edge Function

Last edited: 2/6/2026

If you're having trouble invoking an Edge Function or experiencing CORS issues, follow these steps to diagnose and resolve the problem.

Diagnose the issue

  1. Review CORS configuration: Check out the CORS guide and ensure you've properly configured CORS headers
  2. Check function logs: Look for errors in Functions > Logs in the dashboard
  3. Verify authentication: Confirm JWT tokens and permissions are correct

Proper CORS handling

Make sure your function handles OPTIONS preflight requests:

1
Deno.serve(async (req) => {
2
// Handle CORS preflight requests
3
if (req.method === 'OPTIONS') {
4
return new Response(null, {
5
status: 200,
6
headers: {
7
'Access-Control-Allow-Origin': '*',
8
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
9
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
10
},
11
})
12
}
13
14
// Your function logic here
15
return new Response('Success', {
16
headers: { 'Access-Control-Allow-Origin': '*' },
17
})
18
})

Debugging tools

Supabase provides two debugging tools for Edge Functions:

  • Invocations: Shows the Request and Response for each execution
  • Logs: Shows platform events, including deployments and errors

Access these tools by navigating to Functions > [Your Function] in the dashboard.

Common issues

CORS errors

  • Missing Access-Control-Allow-Origin header in response
  • Not handling OPTIONS preflight requests
  • Mismatched allowed methods or headers

Authentication errors

  • Invalid or expired JWT token
  • Missing Authorization header
  • Incorrect permissions for the authenticated user

Network errors

  • Function not deployed
  • Incorrect function URL
  • Network connectivity issues

Additional resources