Callback handler failed. CAUSE: [unenv] crypto.createCipheriv is not implemented!

I am encountering a problem when trying to deploy my Next.js app to :cloudflare: Workers after adding Auth0. I'm using:

- @opennextjs/cloudflare": "^0.3.3
- "@auth0/nextjs-auth0": "^3.5.0"


This is my route.ts file:
// app/api/auth/[auth0]/route.js
import { handleAuth } from '@auth0/nextjs-auth0/edge';

export const GET = handleAuth();


package.json scripts:
  "scripts": {
    "dev": "next dev --turbopack",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "build:worker": "opennextjs-cloudflare",
    "dev:worker": "wrangler dev --port 8771",
    "preview:worker": "npm run build:worker && npm run dev:worker",
    "deploy:worker": "npm run build:worker && wrangler deploy"
  },


My build runs fine after
pnpm run preview:worker
and I'm able to access the app locally at localhost:8771 ; however, when I try to access api/auth/login, I'm met with the following error:
[wrangler:inf] GET /api/auth/login 302 Found (449ms)
✘ [ERROR] Error [CallbackHandlerError]: Callback handler failed. CAUSE: [unenv] crypto.createCipheriv is not implemented yet!


When I run
pnpm run dev
on localhost:3000 everything is functioning -- I believe it's because I'm able to access the Node runtime, which has the crypto module.

I've found a similar issue here and cont'd here, where vicb mentions that
crypto.createCipheriv
is not yet implemented by workerd.

I saw a post from Brett Willis in #workers-discussions mentioning that :cloudflare: Workers supports the Web Crypto APIs and the equivalents there are
crypto.subtle.encrypt()
and
crypto.subtle.decrypt()
.

I'm new to Next.js and Cloudflare, so if anyone can give me some recommendations on how to resolve this issue it would be greatly appreciated, thanks.
GitHub
Describe the bug When next-auth is used and next-auth related functions are executed, the following error occurs. [wrangler:err] TypeError: Cannot assign to read only property 'cache' of ob...
[BUG] NewtAuth errors with [unenv] crypto.createCipheriv is not imp...
GitHub
crypto.createCipheriv is required by Next Auth. See opennextjs/opennextjs-cloudflare#206 Can we prioritize the implementation of the API? @jasnell The crypto APIs are used by Next from crypto-utils.ts
[Feature] Implement crypto.createCipheriv · Issue #3277 · cloudflar...
Was this page helpful?