1

Why do I got this error:

Proxy error: Could not proxy request /api/v1/management/me from localhost:3000 to http://localhost:8080 (ECONNREFUSED).

Got this axios setting:

axios.defaults.baseURL = "http://localhost:3000/";

And set this in package.json:

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

tried also:

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

And have following call:

axios({
  method: "get",
  url: "api/v1/management/me",
  data: {},
  headers: { crossDomain: true },
})

When I call directly http://localhost:8080/api/v1/management/me I got response from server.

I have following backend, Vapor route setting. Maybe something wrong / specific here?

let protectedAPIRouter = authSessionRouter.grouped("api/v1").grouped(User.guardAuthMiddleware())
let managementAPIRouter = protectedAPIRouter.grouped("management")
János
  • 29,667
  • 30
  • 151
  • 300
  • Assuming your server is running [what happens if you add in a closing `/`](https://stackoverflow.com/questions/45367298/could-not-proxy-request-pusher-auth-from-localhost3000-to-http-localhost500): `"proxy": "http://localhost:8080/"`? – Andy Mar 02 '22 at 01:01
  • None of this hint helped: https://stackoverflow.com/questions/45367298/could-not-proxy-request-pusher-auth-from-localhost3000-to-http-localhost500 – János Mar 02 '22 at 01:17

1 Answers1

0

I would suggest the following solutions:

  1. Try to change localhost to IP address: "proxy": "http://your_IP_address:8080"
  2. Try this construction also:
"proxy": {
    "/api/*":  {
      "target": "http://localhost:8080",
      "secure": false
    }
  }