Error connecting to Azure: Illegal character in password with mongoose 5.0.1 but works in 4.13.9

后端 未结 4 930
鱼传尺愫
鱼传尺愫 2021-02-14 07:11

I have a node.js application that is deployed to azure using CosmosDB and the MongoDB API. My application uses mongoose which works seamlessly in 4.13.9.

My application

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-14 07:40

    For the latest version (v5.0.1) of Mongoose, you'll need to use this syntax to connect to MongoDB like this:

    const mongoose = require('mongoose');
    
    mongoose.connect('mongodb://.documents.azure.com:10255/?ssl=true', {
        auth: {
          user: '',
          password: ''
        }
      })
      .then(() => console.log('connection successful'))
      .catch((err) => console.error(err));
    

提交回复
热议问题