8000 cannot connect to altas due to special characters in password · Issue #9885 · typeorm/typeorm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
cannot connect to altas due to special characters in password #9885
Closed
@orangecrayon

Description

@orangecrayon

Issue type:

[x] question
[] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[X] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[] latest
[ ] @next
[x] 0.3.12 (or put your version here)

HI, I have tried to connect atlas mongdb in nestjs. here is my app.module.ts

TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (
        config: ConfigService
      ): Promise<TypeOrmModuleOptions> => {
        const url = `mongodb+srv://${config.get("MONGODB_USER")}:${config.get("MONGODB_PASSWORD_ENCODED")}@${config.get("MONGODB_URL")}/${config.get("MONGODB_DBNAME")}`;
        return {
          type: "mongodb",
          url: url,
          entities: [EventEntity],
          synchronize: true,
          useNewUrlParser: true,
          useUnifiedTopology: true,
          logging: true,
        };
      },
    }),

Special characters are included in password so encoded password are given by config module.

Unfortunately, i got authentication failed error

MongoError: Authentication failed.

I think this decodeURIComponent in DriverUtils.parseMongoDBConnectionUrl makes this happen.

password: decodeURIComponent(password),

when i change this line as
password: password, //decodeURIComponent(password), then connection successes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0