Problem with proxy in Express / React app
I am trying to use a proxy so that I can run a server using express on the back-end and React using create-react-app on the front-end.
In the tutorial I am following it says I need to add this to package.json on the front-end, in the client folder:
"proxy": "http://localhost:5000/" so I tried this instead, but it doesn't work:
I get this error:
Something is already running on port 5000
I'm a bit stuck and can't get it to work. Any help would be great. Thanks!
Does using just localhost:5000 not work? If not, try using 0.0.0.0:5000 instead of that URL.
I fixed the problem by going into the client folder and setting the port number in the start script in package.json. So it looks like this:
"start": "PORT=3000 react-scripts start"
Also, I changed the proxy in package.json to the following:
Here is a working version of this repl