Problem about using "connect-mongo" in this challenge: "Advanced Node and Express - Authentication with Socket.IO"

Hello Friends!

Everything was OK until I arrived to this challenge:
Advanced Node and Express - Authentication with Socket.IO

Here when I added below code:

const MongoStore = require('connect-mongo')(session);
const URI = process.env.MONGO_URI;
const store = new MongoStore({ url: URI });

I received this error:

throw MongoError.create({
MongoError: database names cannot contain the character ‘.’
at Function.create (/home/runner/boilerplate-advancednode/node_modules/mongodb/lib/core/error.js:57:12)

it seems it’s a problem about “MongoStore” but my connection worked very well before using this “connect-mongo”

you can check out the project up to this point here.

I searched a lot everywhere to find a solution but I still couldn’t solve this problem.
I hope you can help me

Thank You

Challenge: Authentication with Socket.IO
Link to the challenge:

Hello there,

I have not seen this error before. So, the only way around it I can think of is for you to change your database name to something without a . (period)

I might do some more digging, and will let you know, if I find anything more specific/useful.

It might be useful to see your code. Would you mind sharing a link to your project code?

EDIT: This post shows the same error, and it was caused by a space in the “address” (I assume this means the URI string): Error trying to connect to a Mongo DB - JavaScript - SitePoint Forums | Web Development & Design Community

Otherwise, it may work to explicitly define the database name:

new MongoStore({ url: URI, dbName: 'test-app' });

Hope this helps

1 Like

I used below code to solve the problem with you perfect guide:

const store = new MongoStore({
  url: URI,
  dbName: "database",
  useNewUrlParser: true,
  useUnifiedTopology: true

Now everything works smoothy by your help!
Thank you very much dear Sky020! :+1: