-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto
is undefined in API routes (Next13 appDir)
#46852
Comments
I think you should add because |
Thanks that worked! I had no idea Vercel even had a Node runtime. According to the beta docs I put: |
Keep in mind, Vercel and Next.js are different (although the runtime capabilities should match). Both have however a Node.js runtime, which is the default. The Web Crypto API in Node.js has been unflagged on import crypto from "node:crypto"
globalThis.crypto ??= crypto.webcrypto Regarding app repro template, we already have one: https://github.com/vercel/next.js/tree/canary/examples/reproduction-template-app-dir (I'll make sure to add this to the bug report description) |
### What? Link to https://github.com/vercel/next.js/tree/canary/examples/reproduction-template-app-dir from our bug report template. ### Why? To lower the barrier to adding a reproduction even when reporting an App Router-related issue, which is currently behind a flag. (Pointed out in #46852) ### How? Added a link in the issue template. The remaining question is, should we add anything else to https://github.com/vercel/next.js/tree/canary/examples/reproduction-template-app-dir to make creating a reproduction easier? Closes NEXT-789 Related #46852
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 Binaries: Node: 18.14.2 npm: 9.6.0 Yarn: 1.22.19 pnpm: 7.28.0 Relevant packages: next: 13.2.3 eslint-config-next: 13.2.3 react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue
http://plz-make-a-appdir-tpl
To Reproduce
Describe the Bug
crypto
is undefined in API routes, at least locally when runningdev
. This impacts a lot of things like auth libraries (e.g. oauth would have to use insecure plain code challenge instead of S256). Crypto is a fundamental module for writing secure apps.Expected Behavior
Should be able to use
crypto
, it's a browser (V8) supported object.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: