K
K
Ken Jee2019-03-14 20:00:02
System administration
Ken Jee, 2019-03-14 20:00:02

How to set up infrastructure for NodeJS and NodeJS + React projects on Windows 10 system to communicate?

The crux of the matter is this.
There are two projects:
1) front (reactjs + nodejs) localhost:8080
2) back (nodejs) localhost:3000
You need to do ajax on the back from the front, but this results in cross-domain requests, which is not good. How is it possible in a Windows 10 environment to combine front and back within the same domain, for example: front - development.domain and back - api.development.domain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2019-03-14
@Machez

If you have a different origin, you will have cross-domain requests, no matter if you have Windows or something else.
development.domain and api.development.domain are different domains. localhost:8080 and localhost:3000 are the same domain but different origin.
Either set up CORS, or make sure that the back gives the front by the same name and on the same port as your api. You can screw in the proxy if you want to keep it separate, but it doesn’t make much sense in this nodejs will do the same with the same or less effort

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question