Fetch middleware (or specifically jwt decode)
Hey
I'm trying to set up authentication verification on workers but couldn't find how to set up middlewares for jwt authentication
Thanks
3 Replies
Like this: https://github.com/panva/jose, or this: https://github.com/tsndr/cloudflare-worker-jwt#readme
Not sure what you mean by middleware. Pages has actual middleware support, and some routers like hono have their own middleware stuff
GitHub
GitHub - tsndr/cloudflare-worker-jwt: A lightweight JWT implementat...
A lightweight JWT implementation with ZERO dependencies for Cloudflare Workers. - tsndr/cloudflare-worker-jwt
@Chaika I am also looking into how to do this, i believe what they meant by middleware was a "having a worker run on protected routes before forwarding to the api workers" type of thing.
Are you aware of some way to use workers to enforce JWT authentication over particular routes? Or is cloudflare workers limited to one route per worker and no "stacking" capabilities.
Platforms such as vercel support this:
https://vercel.com/docs/edge-middleware
Edge Middleware Overview
Learn how you can use Edge Middleware, code that executes before a request is processed on a site, to provide speed and personalization to your users.
i think netlify supports this even