When the Nextt.js page loaded i encountered this error and am quite confused on what is happening. Could this error be thrown because of errors in my .env.local file? Could anyone help?
Server Error
MongoParseError: Invalid scheme, expected connection string to start with “mongodb://” or “mongodb+srv://”
lib/mongodb.ts (21:13) @ eval
19 | // is preserved across module reloads caused by HMR (Hot Module Replacement).
20 | if (!global._mongoClientPromise) {
> 21 | client = new MongoClient(uri, options);
| ^
22 | global._mongoClientPromise = client.connect();
23 | }
24 | clientPromise = global._mongoClientPromise;
Per the error message, a valid MongoDB Connection String is expected to start with mongodb:// or mongodb+srv://.
You haven’t included a snippet showing how you are creating the connection, but if you are defining a MongoDB URI in your .env.local file it appears to be missing the expected prefix.