Next.js Discord

Discord Forum

Error: Error occured while connecting mongodb

Answered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP
Answered by Alligator mississippiensis
It turned out I needed to update my env variables
View full answer

14 Replies

Alligator mississippiensisOP
@Ray That happened after I had deployed our last changes.
did you forget to run connect? I think there is a function for that?
Alligator mississippiensisOP
I checked twice every function where I usually query the database with mongooose
Alligator mississippiensisOP
yes i am still using that approach
oh maybe I need to update my environment variables in project settings?
no you should call connect() first
xport async function generateMetadata({params}: {params: {id:string}}) {
  await connect()
  const data: TChannel | null = await Channels.findById(params.id);
    return {
        title: `${data?.chnl_name}`,
        description: `${data?.chnl_desc}`,
        creator: `${data?.createdBy}`,
        keywords: `${data?.category}`,
    } as Metadata
}
like what you did in generateMetadata
Alligator mississippiensisOP
yes
Alligator mississippiensisOP
It turned out I needed to update my env variables
Answer
Alligator mississippiensisOP
Problem solved successfully forever