I have installed dotenv while creating the mongodb file. then i got my user and password. to secure that i used .env file like
"${process.env.DB_USER}:${process.env.DB_PASS}"
then it is showing me bad auth. along with that it is showing codeName:
'AtlasError',
[Symbol(errorLabels)]: Set(1) { 'HandshakeError' } this.
CodePudding user response:
I see you have used ""
for the encapsulation and ${}
(template literals):
"${process.env.DB_USER}:${process.env.DB_PASS}"
You have to use backticks like below to make this work and not double quotes:
`${process.env.DB_USER}:${process.env.DB_PASS}`
This one's a common problem that's been done by new folks working with JavaScript's new features.