VibeFix

Guide

Supabase Edge Function 401 Invalid JWT or Missing authorization header

Published by Yosef D., founder of VibeFix

How this guide was made: Written with AI assistance and checked against the sources linked on this page.

Updated

Short answer: a 401 "Invalid JWT" from a Supabase Edge Function usually comes from the built-in JWT check, which runs before your code. Check the response body first. If your project uses the new API keys, Supabase recommends turning that check off (--no-verify-jwt) and verifying the user inside the function. Otherwise, send the signed-in user's access token.

Fixed in your code, then tested live. Get it fixed: a free check first confirms the problem on your live app, usually in 4 to 10 minutes.

Free. No account needed. It usually takes 4 to 10 minutes.

Want it fixed? Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

Why it happens

Every request to an Edge Function passes through a platform-level check before your code executes. When that check is on and the Authorization header is missing, malformed, or signed with a different key, the platform returns a 401 and your code never runs. A 401 can also be returned by your own function code, in which case the function did run.

Possible causes

Official fix steps

  1. Check the response body: "Invalid Token or Protected Header formatting", "Invalid JWT" or "Missing authorization header" means the built-in check failed. (supabase.com)
  2. If the body has a message you coded or is empty, your function ran and returned the 401 itself. (supabase.com)
  3. In the Functions Dashboard, open the affected function's detail tab and toggle off JWT verification. (supabase.com)
  4. Or redeploy the function from the Supabase CLI with the no-verify-jwt flag. (supabase.com)
  5. Know that turning the check off removes the platform's check, so the verification inside your own function is then the only thing that verifies the caller. (supabase.com)
  6. If you keep the check on, send a valid legacy API key with the Supabase client library. (supabase.com)
  7. Put API keys in the apikey header and reserve Authorization for user tokens. (supabase.com)

You can't see it yourself

You're signed in, your customers aren't. While you are signed in, your requests carry your session token. With the check on, the platform expects a valid user JWT in the Authorization header, and if it is missing, malformed, or signed with a different key, the platform returns a 401 before your code runs. That means a caller without a valid token can get a result you never see yourself.

What to do next

App broke after you published it? Our AI agent fixes it in your code, then tests your live app again so you see the result yourself. The first check is free.

Fixed in your code, then tested live. Get it fixed: a free check first confirms the problem on your live app, usually in 4 to 10 minutes.

Free. No account needed. It usually takes 4 to 10 minutes.

Want it fixed? Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

Related: Supabase legacy API keys are going away: will your app break? · Supabase "permission denied for table" (42501) fix

Auth error: {401: invalid claim: missing sub}

Supabase's page with this title says the error appears when supabase.auth.getUser() is called with an invalid JWT, or when a Supabase API key is passed where the user's Auth access token belongs. API keys have no sub claim, which is the field that holds the user ID, so the check fails.

  1. Find the token your function passes to supabase.auth.getUser().
  2. Make sure it is the signed-in user's Auth access token, not the publishable or secret API key.
  3. In the client, send the user's access token to the function in the Authorization: Bearer header.
  4. In the function, read that header and pass the token to supabase.auth.getUser(token).
  5. If you create the Supabase client for each request, check how it is initialised on the server.
  6. Redeploy the function, sign in, and call it again.

Sources

Last checked: 10 November 2026, against the sources listed above.

VibeFix is independent. Lovable, Bolt, Replit, Base44, v0 and Supabase are trademarks of their owners. - Supabase: Auth error 401 invalid claim missing sub

Want it fixed?

Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

It starts with a free check that confirms the problem on your live app, no account needed.

Check my app free

More guides · Shopify store accessibility · About · Your privacy choices