I have a nestjs app which uses typeorm and I am trying to connect to a mongodb (heroku addon). Somehow I can not solve it no matter what I do, I always get an authentication error
"command find requires authentication"
TypeOrmModule.forRoot({
type: 'mongodb',
username:"mydbusername",
password:"mdbuserpassowrd",
database:"mydbname",
port:54681,
url: process.env.ORMONGO_RS_URL,
entities: ['dist/**/*.entity{.ts,.js}'],
ssl: true,
useUnifiedTopology: true,
useNewUrlParser: true,
authSource:"admin"
}),
My connection string looks as follows (changed some values for security)
mongodb://iad2-c12-9.mongo.objectrocket.com:54681,iad2-c16-1.mongo.objectrocket.com:54681,iad2-c16-0.mongo.objectrocket.com:54681/?replicaSet=a72c9007b7bf4f2ead57d6532313123123&ssl=true
CodePudding user response:
Don't user username and password for type mongodb in typeorm, pass these values in URL. I had many times problems with it.
CodePudding user response:
solved it by myself, had to use another authSource (my actual dbname) rather than just admin.
