Cloudflare Workers and Auth0?


I’m testing in the Cloudflare playground.

I want to use Cloudflare worker in front of a static site html site to determine if a user is Authenticated through Auth0.

  • Looks like I can treat a worker like a Javascript app.
  • I need to import createAuth0Client from ‘@auth0/auth0-spa-js’; to the playground.

Any examples on the best way to accomplish this. I didn’t not see any in my searches.

You need to use the build-tools, like Webpack to do that.

Details are in the docs:

Yes wrangler will make this much easier.

There is also an old blog post on how to set up an OAuth auth client using a Worker script that might help.

1 Like

Good post. Im basically separating the main app from help. I really just need to implement the Auth0 portion and if not logged in go back to the main site.

Do you a good example on using Auth0 for just test for isAuthenticated?

I’ve done exactly this: authenticating Auth0 JWT’s in my Cloudflare Workers. I’m also doing it now in an API I’m building with workers.

Good news is you don’t need any extra packages or even Wrangler. Checkout this blog post:

1 Like

That’s awesome!