I
I
IDONTSUDO2019-09-27 12:29:32
Nginx
IDONTSUDO, 2019-09-27 12:29:32

React + Express how to properly deploy a build in production?

I have a React app and an Express server. There is also ubuntu 18.04 and Nginix. When I write npm run build. React asks to run

serve -s build
if I run it static React works. But if I turn off the console, it crashes.
Please tell me how can I run my React app. On my server so that it doesn't crash? And configure the Nginix proxy server. The fact that he would give the static React. And all requests that came from this static were redirected to node js.
PS I know that there is an option to connect via static Express.
spoiler
But this is a task that was implemented too crookedly when I wrote the Vue + Express application

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew Hecc, 2019-09-27
@IDONTSUDO

You need some kind of process manager through which to run serve or the same express.
We use pm2.keymetrics.io/.

T
ThemeZV, 2019-09-27
@ThemeZ

pm2 starts, which starts the server (express). We are going to sell the front build (it's just static).
Nginx proxies API requests and distributes static. There are many manuals.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question