E
E
Evgeny19982021-12-08 10:02:55
API
Evgeny1998, 2021-12-08 10:02:55

React app, how to get data from the server in developer mode?

We have an application on our own server. Previously, the frontend was in native js, now we decided to rewrite the frontend in react JS.
I created an application using the basic create-react-app command and started writing, deployed to the server and everything works, but there was a problem:
In developer mode, when I write the application locally, I cannot access the server API, because. cookies are needed there, which are not there if you do not log in. (And it turns out that I can only check the result of the work after building and uploading the code to the server, this is very inconvenient.
Guys, what should I do? Help, please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Zhivagin, 2021-12-08
@Krasnodar_etc

Specify a hostname for 127.0.0.1 in hosts that matches the cookie domain and open it in a browser
+ you may need to add the host setting in webpack to this
Or you can rewrite the cookie domain through a proxy in webpack and put them on localhost

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question