简体   繁体   English

将 MongoDB Atlas 连接到 Heroku Node.js 应用程序的替代方案

[英]Alternatives for connecting MongoDB Atlas to Heroku Node.js app

I've been working on a simple website using node.js, express, and MongoDB, with Heroku as the platform.我一直在使用 node.js、express 和 MongoDB 开发一个简单的网站,以 Heroku 作为平台。 I had a lot of issues early on trying to connect to my MongoDB Atlas cluster, resulting in Heroku throwing request timeout errors.我在尝试连接到我的 MongoDB Atlas 集群时遇到了很多问题,导致 Heroku 抛出请求超时错误。

After some googling, I surmised that the issue was that the IP addresses Heroku sends requests to my DB from weren't whitelisted in Atlas.经过一番谷歌搜索,我推测问题在于 IP 地址 Heroku 向我的数据库发送请求,这些请求未在 Atlas 中列入白名单。 The simplest solution at that point was to egregiously set up so that any IP is considered whitelisted.那时最简单的解决方案是进行过分设置,以便将任何 IP 视为列入白名单。 Which actually works fine currently.目前实际上工作正常。

My actual question comes down to the fact that whitelisting all IPs hardly seems like a professional way to go about doing things.我的实际问题归结为这样一个事实,即将所有 IP 列入白名单似乎不是 go 关于做事的专业方式。

What is a better solution?什么是更好的解决方案?

You should only allow those IPs from which your application will connect to MongoDB Atlas.您应该只允许您的应用程序将从其连接到 MongoDB Atlas 的那些 IP。 Allow all IPs is a bad practice and could make that MongoDB instance vulnerable.允许all IPs是一种不好的做法,并且可能会使 MongoDB 实例易受攻击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Elastic beantalk Node.js应用程序未连接到Mongodb地图集 - AWS elastic beanstalk Node.js app is not connecting to Mongodb atlas 将 node.js 应用程序连接到 mongoDb Atlas 数据库时出错 - Error in connecting node.js app to mongoDb Atlas database Netlify/React 前端未连接到 Node.js/Express/MongoDB Atlas/Heroku 后端,但在开发/本地工作 - Netlify / React front end not connecting to Node.js / Express / MongoDB Atlas / Heroku backend but works in development/locally Heroku Angular Node.js应用程序未连接到MLAB MongoDB数据库 - Heroku angular node.js app not connecting to mlab mongodb database 使用 mongoose atlas 将 mongodb 连接到 Node.js 应用程序时出错 - Getting Error while connecting mongodb to Node.js app using mongoose atlas 从Node.js泊坞服务连接到Mongodb地图集 - Connecting to Mongodb atlas from Node.js docker services 从 Node.js 与 MongoDB Atlas 连接的问题 - Issues connecting with MongoDB Atlas from Node.js cPanel Node.js 应用程序无法连接到 MongoDB Atlas 集群,但适用于 Heroku - cPanel Node.js app cannot connect to MongoDB Atlas cluster but works on Heroku 无法在heroku上使用node.js连接到mongodb-atlas - can't connect to mongodb-atlas with node.js on heroku Heroku App连接Atlas MongoDB云服务 - Connecting Heroku App to Atlas MongoDB Cloud service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM