我已经通过Zeit部署了我的练习应用程序。我的应用程序只能通过我的机器访问MongoDB地图集上的集群。通过手机或其他设备加载应用程序时,该应用程序似乎未连接到MongoDB。我如何做才能使其他计算机至少能够显示数据库中的数据?
我设置了一个白名单条目,以允许从任何IP访问。
const uri = 'mongodb+srv://mytest:mypassword@cluster0-mqtm7.gcp.mongodb.net/test?retryWrites=true&w=majority'
mongoose.connect(uri,{useUnifiedTopology: true,useNewUrlParser: true,useCreateIndex: true});
const connection = mongoose.connection;
connection.once('open',() => {
console.log("MongoDB database connection established
successfully");
}).catch(error => {
console.log(error);
})
当我在笔记本电脑上输入URL时,会显示数据库中的数据,但是当我尝试使用其他设备时,数据库似乎无法连接。