Next.js Discord

Discord Forum

Database connection dies after first call

Answered
DentFuse posted this in #help-forum
Open in Discord
Avatar
DentFuseOP
Hello everyone, I'm trying to connect to a MongoDB database via the API routes provided by Next. The first requestr goes though and a connection is made to the server, but all further request get lost because it keeps trying to connect to the database again and again. I can seem to get caching working. Please help. Attached my code.
Image

1 Reply