On my page: ‘admin-sokol.netlify.app’ I am always getting this error when loading the site. I tracedback the error to a line of code which connects me to my MongoDB database. When connecting from localhost, no errors are given, but if I try to connect through my site on Netlify, it just won’t connect. How can I prevent this error?
This is my code:
import { MongoClient} from "mongodb";
import { DB_URI } from "$env/static/private";
const client = new MongoClient(DB_URI)
async function startMongo() {
console.log("Starting MongoDB..")
await client.connect()
}
startMongo().then(r => {
console.log("Successfully connected to the database.")
})