NeonN
Neon2y ago
25 replies
urgent-maroon

Neon + Prisma + Next Middleware Runtime Issue

Hey! I am running into a tricky situation using Neon with Prisma + Next + NextAuth, which causes the following error when trying to load my application: A Node.js API is used (process.cwd) which is not supported in the Edge Runtime.

This error is a result of:
1) The Prisma + Neon client config requires adding dotenv.config(); for the Pooler, which uses process.cwd internally
2) To configure NextAuth, I rely on the Prisma client in my Next middleware.ts , which is on the Edge Runtime.

Since the Edge Runtime doesn't support process.cwd, I run into the aforementioned error.

I have also tried simply removing dotenv since it appeared as though my env variables were being set. However, with dotenv removed I get the error Error: All attempts to open a WebSocket to connect to the database failed.

Would love to see a minimal example of how you recommend using NextAuth with Prisma / Neon. Thanks!
Was this page helpful?