next.jsnext-authnext.js13turbopack

How to resolve crypto.getRandomValues() not supported?


After switching to turbopack i have following error:

https://next-auth.js.org/errors#jwt_session_error crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported

Are there any solutions to this?


Solution

  • Adding following code to app\api\auth\[...nextauth]\route.ts removed error.

    import crypto from "node:crypto";
    global.crypto ??= crypto;