Closed
Description
Hi Team
- I have a backend python (flask) server running at localhost:5000, which provides API calls with json data
- Now I have the create-react-app running at localhost:3000, how should I pass the api calls back to localhost:3000?
- Previously, I use "proxy" option in the webpack-dev-server, but now I am not sure how to do it with create-react-app, do I absolutely have to eject it?
Thanks so much for the answer
Activity
gaearon commentedon Jul 28, 2016
We are discussing this in #147.
Can you show the
proxy
configuration you were using?Also, is there a big reason why you can’t just embed
http://localhost:5000
in your requests?ripitrust commentedon Jul 28, 2016
Hi @gaearon
Thanks so much for your reply
the devServer setting I used previously is
About your question
I am not sure if I am right , but if I want to fire a api request from a client served at localhost:3000 to a backend server listening at localhost:5000, I have to make the api request CORS compatible, right?
I think this will cause some problem
also, it means that in all my
fetch(url)
calls, I have to specifically put a complete urlfetch('http://localhost:5000/api').then()
instead of the api endpoint
fetch('/api').then()
gaearon commentedon Jul 28, 2016
👍 Thanks for explaining. I’ll close this in favor of #147 but I’ll make sure to revisit your use case when we work on this.
ripitrust commentedon Jul 28, 2016
Thanks Dan,
great, I will also look at #147 and see if it helps
sergetoure09 commentedon Dec 5, 2017
Hi @ripitrust
I think i have the same issue like you.I have my backend in python listening on port 8080 and i have used npm run build to create bundle.js.I use fetch to request json data from my backend API
and my update function is like this
But i have a service workers NOT found issue when launhing my app.
Anyone can help?
Uglifyjs update for es6 support (facebook#249)
janechou24 commentedon Jun 8, 2018
Actually you could connect your react and flask in one step, just copy your react html file and bundle.js inside the public folder and put it inside the flask static folder, but pay attention about the relative path of the bundle.js, then if you run the flask again, you could see your react server. Hope that will help.