-1

I am trying to deploy my next js app that uses mongodb and mongoose. Everything works fine on localhost however when I deploy to vercel I'm getting this error from the logs:

error logs

I have double-checked my environment variables and everything seems fine with them.

Here is my mongo connection: mongo connection

Here are the pages that bring in data using getServerSideProps:

index page

tours page

Any help would be much appreciated!

  • Please make sure to post code and errors as text directly to the question (and [not as images](https://meta.stackoverflow.com/questions/285551)), and [format them appropriately](https://stackoverflow.com/help/formatting). – juliomalves Jun 13 '22 at 18:55
  • Also, you should not call internal API routes from inside `getServerSideProps`, use the API route logic directly instead. See [Internal API fetch with getServerSideProps? (Next.js)](https://stackoverflow.com/questions/65752932/internal-api-fetch-with-getserversideprops-next-js). – juliomalves Jun 13 '22 at 18:57

1 Answers1

0

Try to make mongo DB queries inside the getServerSideProps function. It is mentioned in the NextJS documentation.

And try to build locally first. Make sure to change the ENV files on the vercel before building.