1

I have a backend written in Go. All works fine and calls from POSTMAN are passing, but suddenly I cannot have React app calling this server because of error:

Proxy error: Could not proxy request /login from localhost:3000 to http://localhost:8080 (ECONNREFUSED).

My go server code:

    log.Fatal(http.ListenAndServe(fmt.Sprintf("localhost:8080"), api.router))

The package.json of React app looks like this:

"proxy": "http://localhost:8080"

I know that I could bind with all interfaces in Go like this:

   log.Fatal(http.ListenAndServe(fmt.Sprintf(":8080"), api.router))

But then Mac OS asks me to Allow this connection and I cannot do it since I'm not the administrator on the computer

I could do it with codesign, but I don't have currently any identities so generating private key, adding it to key chain would also take some time

Any easy way to bypass this?

aldm
  • 343
  • 1
  • 11
  • try to change this localhost to `3000` in `fmt.Sprintf("localhost:3000")` that go server could listen the frontend (React) – nuser137 May 22 '23 at 06:31

1 Answers1

2

Have you tried adding a slash at the end of the react proxy line, like this:

"proxy": "http://localhost:8080/"

This above was found in a similar question to yours here

Also, you can try changing the proxy from localhost to 127.0.0.1:

"proxy": "http://127.0.0.1:8080"