While connecting Azure Cosmos for MongoDB from Next JS - mongodb (version: 5.0.1) I am getting this error -
[next-auth][error][adapter_error_getSessionAndUser]
https://next-auth.js.org/errors#adapter_error_getsessionanduser Command hello not supported prior to authentication. {
message: 'Command hello not supported prior to authentication.',
stack: 'MongoServerSelectionError: Command hello not supported prior to authentication.\n' +
' at Timeout._onTimeout (C:\\Users\\siddh\\Projects\\RareGoods\\blockchain-certificates-admin\\node_modules\\mongodb\\lib\\sdam\\topology.js:284:38)\n' +
' at listOnTimeout (node:internal/timers:569:17)\n' +
' at process.processTimers (node:internal/timers:512:7)',
name: 'MongoServerSelectionError'
}
Mongo helper code is -
import { MongoClient, ServerApiVersion } from 'mongodb';
const uri = process.env.NEXT_PUBLIC_AUTHDB_URI;
const options = { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 };
let client = new MongoClient(uri, options);
let global._mongoClientPromise = client.connect();
I tried changing library version to 4.x.x, but nothing worked. The error is same for each combination.