hoangvvo / nextjs-mongodb-app

A Next.js and MongoDB web application, designed with simplicity for learning and real-world applicability in mind.
https://nextjs-mongodb.now.sh/
MIT License
1.54k stars 286 forks source link

Serverless functions error when deployed to Vercel #116

Open viperfx opened 3 years ago

viperfx commented 3 years ago

All api end points give this error

[GET] /api/user
12:04:20:37
2021-04-18T16:04:21.329Z    e23c93be-e00e-48b5-9ee2-1d6d10ef82db    ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 8000","reason":{"errorType":"RangeError","errorMessage":"Invalid status code: 8000","code":"ERR_HTTP_INVALID_STATUS_CODE","stack":["RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 8000","    at ServerResponse.writeHead (_http_server.js:255:11)","    at ServerResponse._implicitHeader (_http_server.js:246:8)","    at write_ (_http_outgoing.js:685:9)","    at ServerResponse.end (_http_outgoing.js:799:5)","    at onerror (/var/task/node_modules/next-connect/lib/index.js:6:7)","    at next (/var/task/node_modules/next-connect/lib/index.js:69:13)","    at processTicksAndRejections (internal/process/task_queues.js:93:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 8000","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:327:22)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:94:32)"]}
Unknown application error occurred

I have set all the credentials for my mongodb cluster hosted on MongoDB Atlas

hoangvvo commented 3 years ago

This is a possible cause for your issue: https://stackoverflow.com/questions/48097612/connecting-to-mongodb-atlas-com-mongodb-mongocommandexception-command-failed-w. Can you double check your db credential and permissions?