fastify-mongodb: Mongodb connection error
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
3.22.1
Plugin version
4.1.1
Node.js version
16.13.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
Hello. I launched a clustered mongodb and enabled authentication. But the fastify-mongodb plugin does not connect with authentication (AuthenticationFailed). But there is no problem with MongoClient.
Steps to Reproduce
const fastify = require("fastify");
const app = fastify();
app.register(require('fastify-multipart'))
app.register(require('fastify-formbody'))
app.register(require('./FastifyRouter'))
//database
app.register(require('fastify-mongodb'), {
forceClose: true,
url: 'mongodb://localhost:27017/db',
auth: {
username: "username",
password: "password"
}
})
app.listen(port,"hostname",(err,adrs) => {
if (err) {
console.log(err)
} else {
console.log(address)
}
})
Expected Behavior
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (7 by maintainers)
I tested and authentication was successful 👍. I just had to add the last URL authSource = admin