I am trying to configure two servers. Express and react. I was setting up the Google Auth with passport js and I needed to put the link on my react side of the app. For that, I used a proxy and it worked initially. However, after a day or it stopped working. I haven't made any significant change and tried doing all the stuff again and it does not work.
Here is the package.json of create-react-app, place where I want to use a proxy (relative link) and file strucute
. Express server is running on localhost:5000
Weird that it stopped working, did you upgrade react-scripts or anything?
I don't have the time to test this right now, but can you see if it reproduces / works for you on a new project.
Are you sure localhost:5000 is up and running? What's the log saying when you try to do this?
Hi
Though it should work.
Let me test it.
try to specify full url and make sure your localhost:5000 is running
i keep having the same issue, like its trying to get my data from localhost:3000/api/auth (client) instead of localhost:5000/api/auth (server) which i specified in my package.json proxy
The localhost:5000 is running and I didn't update anything. I initially thought about and I started building the app from scratch (I'm just practicing) and it didn't work after that as well. And I also have tried using full URL as well.
the same problem for me
same problem, I remember it used to work.
Having same problem
I just tested this with the latest version and it works fine for me. Can anyone provide more context on this by following the issue template and steps/demo to reproduce this?
Closing because this really needs a reproducing project. Please file a new issue with an example that demonstrates the problem. Thanks!
Restarting client dev server fixed the issue for me.
@realdoug I believe there is a typo in the proxy line of your package.json
"proxy:": "http://localhost:8080"
should be
"proxy": "http://localhost:8080"
@nikovacevic nice catch thanks :)
no working.
src/index is express server, running on 5000.
client is create by cra, noting change.
├── client
├── package.json
├── src
└── yarn.lock
add "proxy": "http://localhost:5000" to client/package.json
restart npm start, and finally the request is
GET http://localhost:3000/hello 404 (Not Found)
not http://localhost:5000/hello
@geminiyellow I believe you have to add an api/ for your api request that are being proxied.
Please refer to the docs: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development
Please do open a new issue if you have additional questions.
Most helpful comment
the same problem for me