1

Can I / Should I host Angular, Node-express and Mongo on same server, say localhost:3000 or somehosting.com/server-address?

Also is it a good practice? I've seen Angular and Node running on same server, but what about adding mongo too?

like everything equivalent to

mongodb://localhost:3000/db
ng serve --port 3000
server listen(3000)

Thanks

2
  • 2
    In my opinion you should serve static files via a real webserver, like nginx or apache and put your API/backend/node server behind the webserver and forward requests as reverse proxy from nginx/apache. PS: Everything is possbile ;) Commented Jan 8, 2021 at 8:54
  • Ok. Trying.Thank you :-) Commented Jan 8, 2021 at 11:06

2 Answers 2

2

As you have not mentioned for what purpose - the answer will be depending on the purpose and context. If you are learning, then running webserver, database and serving Angular static files , all from the same server is not an issue. However, if you are going to have live web app, even with less or moderate traffic, then you must run database on its own server, and the webserver and static Angular files from one server. Of course, for SPAs that expect lot of traffic and real use, it is better to serve your static Angular files from a CDN or storage service like AWS S3, and web and database servers separately.

Happy learning!

Sign up to request clarification or add additional context in comments.

1 Comment

yes its for a professional app. so Im having different server for Mongo and 1 for Node and Angular. Thanks
1

It is best practice to keep the databases(stateful) in different servers then the applications(stateless) unless it is just for testing...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.