Explorar o código

fix migrate.js

Yuki Takei %!s(int64=6) %!d(string=hai) anos
pai
achega
ef062773c9
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      config/migrate.js

+ 5 - 1
config/migrate.js

@@ -16,8 +16,12 @@ const mongoUri = getMongoUri();
 // parse url
 // parse url
 const url = new URL(mongoUri);
 const url = new URL(mongoUri);
 
 
+const authStr = (url.username.length > 0 && url.password.length > 0)
+  ? `${url.username}:${url.password}@`
+  : '';
+
 const mongodb = {
 const mongodb = {
-  url: `${url.protocol}//${url.host}`,
+  url: `${url.protocol}//${authStr}${url.host}${url.search}`,
   databaseName: url.pathname.substring(1), // omit heading slash
   databaseName: url.pathname.substring(1), // omit heading slash
   options: {
   options: {
     useNewUrlParser: true, // removes a deprecation warning when connecting
     useNewUrlParser: true, // removes a deprecation warning when connecting