I am deploying nodejs app with mongodb db with collections/data in it. I have it under the data/db directory. it doesn't have username / password. but with the appfog the service has the user name/password. how does the mongodb service know to start with the db I deployed.
Thanks
When you create the MongoDB client you should pass server host/port and authentication information to it.
usually on hosted services such as Heroku or Appfog this info is provided in evncironment variables which can be accessed with process.env.VARIABLE_NAME
Related
When i create a localhost nodejs CRUD API i am able to make post request.But when i deployed it in cpanel using nodejs software "Incomplete response received from application"
Please share more information as my preliminary guess is that if you are using MongoDB then you cant run it on shared hosting you should use some other DB like Atlas MongoDB or Mlab
I recommend you host it on Heroku as its also free
Deploy APP to Heroku
Use Any thirParty mongoDB service
Test your CRUD API
i am making NodeJS app hosted on heroku and using MongoDB atlas as a backend.When i am sending POST request to app via POSTMAN it is showing:
Error: 503 service unavailable
In my opinion node app is failed to connect with MongoDB atlas cluster.If so then how can i connect it with MongoDB.
THANKS
See Connecting Heroku App to Atlas MongoDB Cloud service, you need to either connect via SSL or whitelist the relevant Heroku IP address ranges for your app.
I have an API written in express.js, the db is mongo. I'm planning to use mlab
to deploy the DB. I don't really understand where to deploy the express api? Can i use AWS for api only? Is there any provider where i can host my DB and API at the same time? What are the best practices for deployment of these APIs?
"Best practices" is based on your needs. The current trend is to move everything to the cloud. So services such as AWS Elastic Beanstalk, Heroku, Azure App Service, and more will allow you to easily host your Express app with little to no setup/configuration on your end.
Each of the providers I've listed above have their own flavor of a NoSQL document storage.
Heroku - mLab add-on
AWS - DynamoDB
Azure - Cosmos DB
If you're set on NoSQL, then it's probably less of a headache for you to stick with mLab.
Here is my approach in AWS for simple apps
Number of servers :1
Application server and DB server are in same machine.
Setting up mongodb and nodejs in ec2 server with nginx as web server.
Nginx listen on port 80 and nodejs application running on port 3000
Using nginx reverse proxy to access the API endpoints
I am now trying to host my Angular, Node, MongoDB app on DigitalOcean. I have succesfully set up the two Droplets, one for Node Backend and one for MongoDB Database. Until now I was using a local link to connect to local database like the following link mongodb://localhost:27017/creditApp .
How do I connect my Node app hosted in Droplet to the MongoDB hosted in another Droplet? The database has admin password set up, also has allowed the IP address from my backend in the ufw list. I assume it needs a config object with admin name, password, ssh key .pub file etc and attach that object while trying to connect it, but I am not quite sure how to do it. How do I get this done?
Any help will be highly appreciated, thanks in advance.
Currently I am deploying my app on a Heroku server. The app is written on Node.js and uses MongoDB as a database source. I'd like to know how I can upload my own database on Heroku without having to use any add-ons or databases provided by Heroku.