Reputation: 250
I am new in react and I haven't use digital ocean before to deploy any code.
I want to deploy a react app on digital ocean. After some research I went through some tutorial and documentation but I couldn't able to get step by step guide in easy language. Going through some videos and documentation I got to know that it can be possible by nginx
and it also provide ssl
certificate. Also, I wanted to connect to my domain which is on digital ocean as well. I referred this documentation.
Steps that I did -
npm run build
.node.js
on digital ocean.npm
on digital ocean.nginx
.PM2
used on server.After doing all this steps, I can't able load my app. It shows broken links of assets.
Note:I am using digital ocean's console.
Upvotes: 0
Views: 3234
Reputation: 5972
You don't need PM2 for your React app deployment, you can just use Nginx.
npm run build
creates a build directory with a production build of your app.
And update /etc/nginx/sites-enabled/default
with the below content:
server {
listen 80 default_server;
server_name _;
include /etc/nginx/mime.types;
root ABSOLUTE_PATH_TO_YOUR_BUILD_DIRECTORY;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
Now restart the nginx
and you will see your app running on the ip address of your droplet.
sudo service nginx restart
Upvotes: 2