Skip to content
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

Trying to use next-auth on Cloudflare with Mongodb but it's failing #6089

Closed
geekyayush opened this issue Dec 16, 2022 · 1 comment
Closed
Labels
mongodb @auth/mongodb-adapter question Ask how to do something or how something works

Comments

@geekyayush
Copy link

Question 💬

Hello,

I am trying to deploy my Next app on cloudflare pages with experimental-edge runtime.
I am using MongoDB Adapter but the build is failing with the following error:

I would really appreciate if someone could help me in deploying the app to cloudflare pages.

Error logs:

14:53:39.680 ▲ Failed to compile.
14:53:39.681
14:53:39.681
14:53:39.681 ▲ ./node_modules/bson/dist/bson.browser.esm.js
14:53:39.681 ▲ Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
14:53:39.681 ▲ Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
14:53:39.681
14:53:39.681 ▲ Import trace for requested module:
14:53:39.682 ▲ ./node_modules/bson/dist/bson.browser.esm.js
14:53:39.682 ▲ ./node_modules/mongodb/lib/bson.js
14:53:39.682 ▲ ./node_modules/mongodb/lib/index.js
14:53:39.682 ▲ ./src/lib/mongodb.ts
14:53:39.682
14:53:39.682 ▲ ./node_modules/bson/dist/bson.browser.esm.js
14:53:39.683 ▲ Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
14:53:39.683 ▲ Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
14:53:39.684
14:53:39.684 ▲ Import trace for requested module:
14:53:39.684 ▲ ./node_modules/bson/dist/bson.browser.esm.js
14:53:39.684 ▲ ./node_modules/mongodb/lib/bson.js
14:53:39.684 ▲ ./node_modules/mongodb/lib/index.js
14:53:39.684 ▲ ./src/lib/mongodb.ts
14:53:39.684
14:53:39.684 ▲ ./node_modules/@babel/runtime/regenerator/index.js
14:53:39.684 ▲ Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
14:53:39.685 ▲ Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
14:53:39.685
14:53:39.685 ▲ Import trace for requested module:
14:53:39.685 ▲ ./node_modules/@babel/runtime/regenerator/index.js
14:53:39.685 ▲ ./node_modules/next-auth/core/errors.js
14:53:39.685 ▲ ./node_modules/next-auth/utils/logger.js
14:53:39.685 ▲ ./node_modules/next-auth/core/index.js
14:53:39.685 ▲ ./node_modules/next-auth/next/index.js
14:53:39.685 ▲ ./node_modules/next-auth/index.js
14:53:39.686
14:53:39.686 ▲ ./node_modules/@babel/runtime/regenerator/index.js
14:53:39.686 ▲ Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
14:53:39.686 ▲ Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
14:53:39.686
14:53:39.686 ▲ Import trace for requested module:
14:53:39.686 ▲ ./node_modules/@babel/runtime/regenerator/index.js
14:53:39.686 ▲ ./node_modules/next-auth/core/errors.js
14:53:39.686 ▲ ./node_modules/next-auth/utils/logger.js
14:53:39.687 ▲ ./node_modules/next-auth/core/index.js
14:53:39.687 ▲ ./node_modules/next-auth/next/index.js
14:53:39.687 ▲ ./node_modules/next-auth/index.js
14:53:39.687
14:53:39.687
14:53:39.687
14:53:39.687 ▲ > Build failed because of webpack errors
14:53:39.687
14:53:39.782 ▲ error Command failed with exit code 1.


How to reproduce ☕️

  1. Dependencies:
"react": "^18.2.0",
"react-dom": "^18.2.0",
"next": "13.0.0",
"next-auth": "^4.16.4",
"@next-auth/mongodb-adapter": "^1.1.1",
"mongodb": "^4.11.0"
  1. Follow this documentation to use MongoDB for storing user accounts: https://next-auth.js.org/adapters/mongodb

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

@geekyayush geekyayush added the question Ask how to do something or how something works label Dec 16, 2022
@github-actions github-actions bot added the mongodb @auth/mongodb-adapter label Dec 16, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Dec 16, 2022

next-auth is not compatible with the Edge Runtime right now, but we are working on a compatible package, see the announcement here: https://twitter.com/balazsorban44/status/1603082914362986496?t=Cg2NTDM0E-x5MFWa2bLe4A&s=19

That said, the mongodb adapter will likely need an upgrade too, I'm assuming that mongodb isn't compatible either. Is it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mongodb @auth/mongodb-adapter question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

2 participants