Validating supabase JWT token locally (without making a request to their API) [solved]

I have a nextjs api handler that calls this to validate the user (and then makes a DB request using user.id):
const { user } = await supabase.auth.api.getUserByCookie(req);
const { user } = await supabase.auth.api.getUserByCookie(req);
The issue is it takes about 600ms for that to run, since it makes a request to supabase. Is there a way to validate the cookie locally?
1 Reply
dan
dan3y ago
If supabase is using a JWT on the cookie then you can verify the JWT is valid locally. There are libs that exist which can do that for you.

Did you find this page helpful?