How can I successfully publish my React project on a DigitalOcean server?

0
0
Asked By TechieTurtle93 On

Hey everyone, I've recently purchased the domain bearandevu.com through GoDaddy, and I've set up DigitalOcean with namespaces. I created a droplet and uploaded both my backend (Node.js) and frontend (React) folders. I was managing the backend using PM2, but I've hit a wall trying to connect the frontend to my domain, which has been super frustrating. I even attempted to run the frontend with PM2 as well. In the middle of adjusting UFW permissions, I lost my SSH connection to the server. Now, I can't access it via the DO root console SSH, nor through my normal terminal. I thought I could fix it using the recovery console, but while trying to sort out the SSH, I inadvertently blocked access to the backend. UFW shows that port 3000 is open, but now I'm unable to connect or see the frontend at all. I'm really stuck, so any help would be much appreciated!

2 Answers

Answered By CodeMaster77 On

You can use the DigitalOcean console to re-enable SSH access. To publish your React app, first build it using 'npm run build'. Then, install Nginx and copy the build files to the '/var/www/html' directory. Make sure to set your domain in the Nginx config and restart Nginx afterwards. Your backend can remain managed by PM2 as is.

Answered By Aaron Garnes On

Have you considered using Vercel for deploying your frontend? It makes things really easy to manage. But just so you know, I understand wanting both your backend and frontend on the same server, so make sure your server settings are all good!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.