Category: Supabase and databases

Supabase Edge Function: Invalid JWT

Read this guide in Polish

The function returns 401 or Invalid JWT, while a simple query to the database works. A function request may require a correct user token or a different JWT verification configuration than that used by the client.

How to determine the source of the error

Check the Authorization header and whether the current user access token is being transmitted rather than the public anon key as a session.

Verify the verify jwt setting for this specific function and the required authorization model.

What to do step by step

1. Create a function via SDK with the current session context or transfer the correct token from a trusted server.

2 . If endpoint is to be public, disable verification only consciously and with your own operation control mechanism.

How to check the score

The authorized request works and the expired or incorrect token does not open a private function.

What to do

Do not disable verification for the entire project only in response to individual 401.