Deploying MERN app using a Node.js Droplet and DreamHost
I’ve built a MERN app and am using yarn as a package manager.
I’ve been able to get my backend running on my droplet using pm2 and it seems stable.
How do I then go about linking that running server.js process to my front-end?
I’ve purchased my domain on DreamHost and have the nameservers on DreamHost pointing to ns1.dreamhost.com , ns2.dreamhost.com , ns3.dreamhost.com and created the proper A records in my Droplet. I can go to the ip address where it’s being ran and I get a “Unauthorized: No access token found” error which makes sense as no user has logged in/is logged in.
I have my project folder that contains a ‘backend’ folder and 'client’ folder on my Droplet. On my host machine during development, I’d simply cd into the backend and run
yarn run dev and then cd into client and run
yarn start to get up and running (client is localhost:3000 which has a proxy to localhost:5000 which the server is being ran on).
My initial thought was perhaps I
yarn build in my client folder to get a production build and toss that on DreamHost as my frontend, and since I have the DNS pointing to DigitalOcean the api calls will run successfully??? I’m unsure as to how to go about this and there’s not that many resources online that go into this in-depth.
Thanks in advance for any help!