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.
- 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: https://workers.Cloudflare.com/docs/quickstart/cli-setup/
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.
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: https://liftcodeplay.com/2018/10/01/validating-auth0-jwts-on-the-edge-with-a-Cloudflare-worker/