Auth0 token - Node Jsonwebtoken - Cloudflare Workers


  1. I’m using the react auth0 provider to get an Auth0 token.
  2. I’m taking this TOKEN and passing it via url param (as a test for now, eventually it would be a header) and try to decode it using jsonwebtoken verify function
  3. The token is not getting verified.

This is my code (I’m setting type = “webpack” in my wrangler.toml so I can import modules):

import { verify } from 'jsonwebtoken'

addEventListener('fetch', event => {

async function handleRequest(request) {
  const url = new URL(request.url)
  const { searchParams } = url
  let token = searchParams.get('token')

  if (url.pathname === '/auth') {
    try {
        { algorithms: ['RS256'] },
        function(err, payload) {
          console.log('payload', err, payload)
    } catch (err) {
      console.log('error decoding', err.message,

  return new Response('No response', {
    headers: { 'content-type': 'text/plain' },

The console.log(‘payload’, err, payload) is not showing an err or a payload . This is what the Cloudflare logs are showing:

"logs": [
      "message": [
      "level": "log",
      "timestamp": 1654695913617

How can I verify this token? Appreciate any ideas.

Thank you!

Hi @tools1,

Welcome to the Auth0 Community!

Are you seeing a valid token in your worker? You can print it and decode manually using

Is your secret set up correctly? You may want to consider fetching it directly from your tenant using the code snippet here: