Hey everyone π,
Weβre building a Next.js app and our /api/user/create route works perfectly in local dev β it creates a MongoDB user, hashes the password with bcryptjs, and returns 200.
But on Vercel, the same route gives us:
- β
500 Internal Server Error(delayed ~1.8 seconds) - Weβve already:
- β
Whitelisted
0.0.0.0/0in MongoDB Atlas - β
Verified
MONGODB_URIis correct in Vercel env vars - β
Logged
process.env.MONGODB_URIin the route and confirmed it loads - β Route connects successfully locally and returns 200 every time
- β
Used
console.log()andconsole.time()to confirm that the error occurs after reaching MongoDB in production
- β
Whitelisted
We're using:
mongoosefor DB connection (lib/mongodb.ts)bcryptjsfor hashing- App Router with
app/api/user/create/route.ts
Weβre even returning the error stack trace in production and still just get a generic failure. Logs on Vercel donβt show the error clearly due to retention limit.
Any ideas why Vercel would fail where localhost succeeds?
Thanks in advance β we're stumped and happy to post snippets if needed!