Strapi: Strapi now disrespecting dbname from database URI

Created on 14 May 2019  路  3Comments  路  Source: strapi/strapi







Informations

  • Node.js version: v10.13.0
  • NPM version: 6.9.0
  • Strapi version: 3.0.0-alpha.26.2
  • Database: Mongo Cloud Atlas
  • Operating system: Linux
  • (Optional) Link to your Project:

What is the current behavior?

We use Mongo Cloud Atlas with a database URI of the format: mongodb+srv://USER:[email protected]/PROJECTDB.

Today we upgraded Strapi from 3.0.0-alpha.12.7 to 3.0.0-alpha.26.2. After doing so, Strapi no longer connected to the correct database (PROJECTDB, as specified in the URI), and instead was connecting to and creating a database called strapi.

To fix this, I have had modify our production database.json to explicitly specify a database name,

{
  "defaultConnection": "default",
  "connections": {
    "default": {
      "connector": "strapi-hook-mongoose",
      "settings": {
        "client": "mongo",
        "uri": "mongodb+srv://USER:[email protected]/PROJECTDB",
        "database": "PROJECTDB"
      },
      "options": {
        "ssl": true
      }
   }
}

Steps to reproduce the problem

  1. Use Strapi with a database uri that specifies a database name other than strapi.
  2. Observe incorrect database usage.

What is the expected behavior?

I expect Strapi to use the database specified in the URI. As it previously worked this way, it seems highly likely to be a bug.

Suggested solutions

This is somewhat similar to closed issue https://github.com/strapi/strapi/issues/1474 in which connectionOptions were clobbering database uri params. Perhaps there is something to be learned from how that was solved.

help wanted

All 3 comments

@doublemarked short answer it wasn't, your best bet is to move to separate variables as no one has worked on repairing the URI option.

Your welcome to look at it and submit a PR, note it may be blocked by the beta though.

Hello @doublemarked !
Thank you for this feedback.

You can find here the documentation (in the tab MongoDB) how to use Strapi and MongoDB Atlas

馃摎https://strapi.io/documentation/3.x.x/guides/deployment.html#heroku

About using uri or connection key from database settings, we have other issues about this topic.
But I'm agree we have to make this configuration fully usable.

Hello @lauriejim - can you please link the "other issues on this topic" that remain open, so that I might track your progress on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chaitanyya picture chaitanyya  路  3Comments

isabellachen picture isabellachen  路  3Comments

rahilwazir picture rahilwazir  路  3Comments

mnlbox picture mnlbox  路  3Comments

peeomid picture peeomid  路  3Comments