I am trying to connect with MongoDB with the node
and access control is also enabled
using URI mongodb://USER:PASSWORD@HOSTANME:27017/DATABASE_NAME
but it is not connecting to the database but when I add ?authSource=authDB at the end of the URI it is connected successfully
is there any way to connect with MongoDB without specifying authSource at the end of the URI?
when I add ?authSource=admin after the db name it will connect.
if I remove ?authSource=admin at the end it will not connect.
My USER is created in admin db.
when adding?authSource=admin in the last which worked.
but I want it without ?authSource=admin it should work as well get this error in error log
“error”: “UserNotFound: Could not find user "shakir_usr1" for db "shakir_db"”}
You can connect to MongoDB without specifying authSource in the URI if the authentication database is the same as your target database. Otherwise, include it for clarity and security.