I’d like to sign my own tokens rather than call the /token endpoint constantly (which I’ve got working, but I just want to avoid an extra API call in our app)
I’ve followed the instructions and checked out the example worker in the docs.
In my case I’m using Next.js and I’d like to use a Next API route rather than a Worker.
I’ve repurposed the example Worker code; it has a couple of deprecated functions (
btoa()) which I updated (with
Buffer.from(jwkKey, 'base64') and
buffer.toString('base64') respectively). However the problem I have is that crypto is not available at all - it imports as undefined, so
I’m not sure if this is because I’m running on localhost, and crypto requires a secure context, but localhost is supposed to be considered a secure context, and I am using the crypto module elsewhere in my code without any trouble (but not
Is there any updated advice on this? I’m using Node 14.17.1