HOW to deploy a MERN APP to production, without using firebase or heroku or aws - node.js

So people, I'm planning to build a website with MERN Stack and host it from my local machine. How to do that without using aws or fire base.
How to use my machine as Backend and database(express, node and mongodb hosted in local host) for the react frontend (hosted in www.someurl.com).
PS: I have already created a site using firebase and firestore as backend.
https://t-heros.web.app/
Thanks in advance.

One thing is you need to keep your local machine 24*7 for your app to work throughout the day. And for your answer you can expose your localhost to public domain by using static IP address and routing applicable from your router with appropriate firewall rules, all this also requires effort and maybe static IP address requires purchase. With both these together your React app can access the localhost on your machine for operations.

Related

How to deploy Front end and backend on Plesk

I am trying to deploy my Front-end React and backend Rest api's in node.js, The server is being accessed with plesk dashboard. I was successfully able to deploy my front-end following these steps by deploying build and changing root folder https://www.plesk.com/blog/product-technology/node-js-plesk-onyx/
But here I do not find a way to deploy my backend node.js rest api on different port as we do in vps via terminal, i couldn't find way to access terminal either.
On Creating subdomain and redoing the same steps to deploy node.js-plesk I get ip address not found api.domain.digital’s server IP address could not be found.

Can I only deploy the server side of my react native app to Heroku?

I have a react native app that I'm building using expo. For the backend, I am using node.js and Express.
My app hierarchy is such that I have a frontend folder and a backend (server) folder. For example,
Root
|
|Frontend
|Various screens & associated files
|Server
|Routes & other files
For my project, is it possible to just host the backend and not the rest of the app? Such that when I fetch data in the frontend using HTTP requests, instead of routing through localhost (http: //RandomIP:PORT/route) I would use the heroku address as the routing address. I would also host the SQL database along with it.
I tried to follow along with the Heroku documentation, but it seemed like that was for hosting the entirety of the app / web apps instead of mobile, and I ran into constant errors.
I would like to point out that, unlike web pages, mobile apps cannot be hosted on the server and fetched on-demand. In other words, do not try to upload your react-native code to Heroku instead just upload your backend only and then make HTTP requests through the URL provided by Heroku after you have deployed your code.
Therefore go into your backend codebase, initialize a git repository and just deploy that Heroku. Also, you will need to host your SQL database on another service such as Google's Cloud SQL or Amazons AWS Database Services.

Google Cloud App Connecting to Atlas MongoDB

I am a newbee to Google Cloud, however, I setup the project based on Standard App Engine based for my Node.JS application. I downloaded the code from GIT and able to deploy. In my code, it tries to make a Mongo connection to my Replication Server that is hosted at Atlas MongoDB (I guess it's on AWS EC2 instance). I have access control enabled so only server to server with known IPs can connect to my MongoDB.
Obviously I was expecting the connection from my freshly deployed app to fail. So to remediate I want to add the external IP of the instance from Google Cloud (whatever is the Public IP that is seen) to Mongo Network Access. I tried a few IP address I thought are the right ones but it's not working. I see the connection is trying to make to Atlas but it's failing because I am not sure what Public IP address is seen from AppEngine (Docker Instance?)where my app is running.
I tried 0.0.0.0/0 - open to all clients and my app works just fine, however I definitely don't want to open MongoDB access to entire world. If anybody knows more about Google Cloud please help.
Thanks in advance for replying if you have important info to share.
Google App Engine doesn't have an External/Static IP that you can refer. This can be achieved by using a VM on Google Compute Engine that has an External IP with proxy to your App Engine.
Besides that, there is a Feature Request open for this to be checked by Google that you can access here:
Provide static IP for outbound urlfetch requests
Besides that, you can access the documentation Static IP Addresses and App Engine apps, to find out more information on options already available on App Engine.
Please, let me know if the information helped you.

Alternate of nginx server

Currently I am using aws ec2 instance to host my backend and frontend . Backend is in nodeJs and frontend is in angular. ALso using route 53 for routing . and bought domain from goDaddy.
I have used following steps for hosting.
for backend :
clone my backend files on ec2 instance.
run backend nodejs program using pm2(used to run nodejs in background)
used nginx as reverse proxy to point localhost to my sub domain.
for frontend:
cloned frontend production files on ec2 instance.
used nginx to point frontend file to my main domain.
Now nginx is little bit complex to handle for me. Is there any way to avoid nginx or to host though any other way ?
Thank you for your time.
If your frontend app uses angular, then presumably it's a 'Single Page App' that is only dynamic in the sense that it makes some kind HTTP calls to an (RESTful?) API provided by your nodeJS application.
If this is the case, then you can host the built version of the angular app in a public S3 bucket configured as a 'static' site, which will still be able to communicate with your backend via angular's HttpClient. You can use Route53 to point your bought domain at the bucket's index.html file, and also set up a CloudFront distribution if desired.
Your nodeJS app will continue to live on the EC2 instance, although you could consider either using Elastic Beanstalk to deploy the backend app for you, or at least setting up yourself a load-balancer and autoscaling group to give you fault tolerance and availability for the backend.

How to deploy Node.js Express server + Vue.js app on AWS EC2

I'm setting up my website which would run on an AWS Ubuntu EC2. It is a Vue.js SPA relying on a Nodejs Express app with API calls and socket.io. So far both apps are working, the backend is on my AWS EC2 free tier, behind an Elastic Load Balancer, the frontend is on my machine since I working on it. Now I would like to deploy the frontend to my AWS EC2 also but I'm confused how to do it correctly. The tutorials I've found are using nginx but I'm not sure that I need nginx as I already have AWS ELB. Any advices would be great :)
as is says "If you are developing your frontend app separately from your backend - i.e. your backend exposes an API for your frontend to talk to, then your frontend is essentially a purely static app" here
I would choose s3 to host vue app because it's static and can be served using s3 and
I will choose EC2 for hosting my API (server code) and also i'd make an elastic IP to talk to my ec2 server so that on restart i don't have to handle the dynamic IP's
Steps to make your website live
First pull yout node express server on your ec2 instance
start your node express server use pm2 to serve it as an service
expose the served port from security groups of the ec2 instance
make an s3 bucket on aws and upload files to it
Tip: just click upload button after dropping your files to s3 do not go clicking next
after uploading select all the uploaded files and then mark as public
after uploading go to properties of that bucket and then choose static web hosting and type index.html the asked field
** TIP: do not use a load balancer for this application use only when you distribute your system across multiple ec2's**

Resources