mongo-express / mongo-express

Web-based MongoDB admin interface, written with Node.js and express
MIT License
5.56k stars 955 forks source link

Connect to mongo Atlas #584

Open noyessie opened 4 years ago

noyessie commented 4 years ago

Hi

Please i have a cluster on MongoAtlas. I want to connect mongo express to the cluster.

Which configuration should i change for that ?

FossPrime commented 3 years ago

Got it working by cloning the repo and beating the config.js file to death. Don't forget to allow your network's IP in the Atlas control panel.

I had to enable SSL, and disable certificate verification. My connection string looked like this mongodb+srv://kanyewest:greatestofalltime123@cluster9.mesohoni.mongodb.net/groupies

other options... needed to squash warnings:

connectionOptions: {
      useUnifiedTopology: true,
      ssl: true,
      sslValidate: false,
      sslCA: sslCAFromEnv ? [sslCAFromEnv] : [],
      autoReconnect: false,
      poolSize: 4 // This is a lot...
}

Why I'm using mongo-express: MongoDB Connect was eating my CPU and battery... my custom gui has a couple annoying bugs I can't be bothered to fix

A big part of the issues we are running into is the mongodb driver has good defaults and auto detects SSL... but the config.js has defaults that override the driver, meaning you have to manually specify a lot of things you would otherwise leave up to the driver.

There seem to be some parsing issues with the connection parameters as well.. particularly with handling booleans passed via env as strings

FossPrime commented 3 years ago

Added PR #677 to address a few of the issues... there is a lot of code from the repo and Bluemix that breaks Mongo URI's without modifying the config file per server you connect to.