Edge Function returns 401 Invalid JWT before execution (Verify JWT OFF, no logs) #42534
Replies: 4 comments
|
Hi @rahulramesh2305-arch 💚 Also, look into your You can see all deploy options here. |
|
Thanks for the pointer — confirmed, the Verify JWT toggle was ON. Turning it OFF fixed the issue immediately 👍 |
|
this is almost always caused by the supabase gateway verifying the JWT before it reaches your function, not by anything inside your function code. what's happening: when you call a supabase edge function, the API gateway checks the common causes and fixes:
const { data: { session } } = await supabase.auth.getSession()
const { data, error } = await supabase.functions.invoke('my-function', {
headers: {
Authorization: `Bearer ${session.access_token}`
}
})
const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY)
const { data, error } = await supabase.functions.invoke('my-function')
[functions.my-function]
verify_jwt = falsedocs ref: https://supabase.com/docs/guides/functions/auth debugging tip: add a |

Uh oh!
There was an error while loading. Please reload this page.
Hi everyone 👋 I’m stuck with an Edge Functions issue and could really use some help.
TL;DR
Edge Function always returns 401 Invalid JWT BEFORE execution. Verify JWT is OFF. No logs. Auth + REST work fine.
Details:
enter-matchingreturn { ok: true }) also failsHeaders sent on every request:
What works:
Observations:
This looks like the Edge Functions gateway rejecting the request before the function executes, not a bug in function code.
Questions:
Happy to share project ref or screenshots if needed.
Thanks a lot 🙏
All reactions