#Supabase and Cloudflare Workers

1 messages · Page 1 of 1 (latest)

edgy flume
#

How do I protect a Cloudflare Worker route to authorize only if the user is authenticated on Supabase?

I'm using Cloudflare Pages Function to create a worker inside the Cloudflare Pages: https://developers.cloudflare.com/pages/platform/functions/

I also posted this question on Stackoverflow: https://stackoverflow.com/questions/76360348/supabase-and-cloudflare-workers

Pages Functions allows you to build full-stack applications by executing code on the Cloudflare network with Cloudflare Workers. With Functions, you …

unreal peak
#

im pretty sure supabase use jwts (can be wrong) so you should use that for your own advantage.

#

haven't used supabase in a long time.

edgy flume
#

It does use JWT. I can get this in the Worker using: const token = context.request.headers.get('Cookie'). But I don't have access to the user in the Worker using const {user, error} = await supabase.auth.getUser(token). How can I somehow validate this JWT token so I could see if this user is authenticather?