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/0
in MongoDB AtlasVerified
MONGODB_URI
is correct in Vercel env varsLogged
process.env.MONGODB_URI
in the route and confirmed it loadsRoute connects successfully locally and returns 200 every time
Used
console.log()
andconsole.time()
to confirm that the error occurs after reaching MongoDB in production
We’re using:
mongoose
for DB connection (lib/mongodb.ts
)bcryptjs
for 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!