E
E
Egor Astreiko2019-08-11 01:48:05
Node.js
Egor Astreiko, 2019-08-11 01:48:05

How to combine react and express in fullstack development?

Hello everyone, when I was developing frontend on react, I just needed to run build at the end of the work and give the assembled project.
When developing the frontend, I had the address of a ready-made server.
Now I want to understand the backend. create react app runs on port 3000, express on port 3001 and available
at: fronted
- localhost:3000
backend - localhost
: 3001 my-domain.loc. Create a temporary ssl certificate for the entire project (both frontend and backend). Whatever from the frontend, I made a request (using graphql) to the /server/graphql server.

After that, collect the entire project and upload everything as one unit to the server.
Please explain if this is possible and how it works in practice (react app + express server on vds or vps)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SANTA2112, 2019-08-11
@SANTA2112

The cra doc describes how to proxy requests:
link

M
McBernar, 2019-08-11
@McBernar

On the server, you will need a running node that can run the express on the same localhost. It's just that in the nginx config you will need to proxy the request from mysite.ru/api to localhost:3001
And on the local you can work like this - react on 3000, api on 3001.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question