Next.js Discord

Discord Forum

(Nextjs V13 with BUN) Api ERROR 504/502 when I host the website on vercell/netlify

Unanswered
Pulx/Mars posted this in #help-forum
Open in Discord
So I recently uploaded a website and I got an error from the api each time I wanna do a action with my mongodb using mongoose. On localhost it's taking a lot of time (2-9 seconds) to make an action that uses mongodb. I uploaded my websites on vercel and after I tried to login/create an account on my website, it's not doing anything because when the request is send, it's taking too much to load and I guess that's why I got error code 504 or 502. I have my backend in frontend because I use nextjs v13.
My api works like a normal api like I have a libs folder where I have my mongo connection function, a schema folder with schemas and the API folder where I have my API. As I said,my API works on localhost okay, sometimes is slow,sometimes is faster.

Check out the photos to see an example of how my code look like.

What should I do? How I can fix it? Is this a mongodb problem only because when I try to do an action that includes mongo it's showing that error? I changed both regions to Washington S(vercel) and N Virginia (mongodb) to get a better performance but sadly it didn't work...

Should I rebuild my api? Should I use another database?

Help! I have 8 days to finish this project and this problem is impossible for me to solve!

0 Replies