Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS could not proxy request from localhost:3000 to localhost:3003

I am writing a SPA using create-react-app and am using an expressjs server as my backend. For development I run my frontend test server on port 3000 and my backend expressjs test server on 3003.

I make many API calls client side using Axios so for development convenience I have defined proxy: "http://localhost:3003" in my package.json

This works fine on my laptop, but when running on my workstation I constantly get the error when accessing my app:

Proxy error: Could not proxy request /sockjs-node/487/wrst1bub/websocket from localhost:3000 to http://localhost:3003/. See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).

I have no idea where this is coming from and I do not use sockjs in any capacity as far as I know. This is a console error and it does not crash my app but it is very annoying and I would like to get rid of it. Any help is greatly appreciated.

like image 299
slugz Avatar asked Apr 02 '19 20:04

slugz


People also ask

How do I fix a proxy error in react JS?

To resolve this, one has to add “secure: false” in package. json defined in ReactJS and restart again.

How add proxy to package JSON in react?

To configure the proxy, you'll need to add the following line to your package. json . Then, in your React app, you can make API requests by using relative paths. For example, http://localhost:8000/api/todos becomes /api/todos .


1 Answers

In my case, I was using Firefox and for some reasons, it gives me the same error. I tried to use Chrome and it worked!

like image 146
Raouf Fathi Avatar answered Oct 13 '22 18:10

Raouf Fathi