Error occured while trying to proxy to: localhost:3000/auth/google. http-proxy-middleware

Error occured while trying to proxy to: localhost:3000/auth/google. http-proxy-middleware

enter image description hereI have react-node-webpack app. I am implementing google oauth with passport.js. I need to use proxy server to make requests to google. this is my setup:

const { createProxyMiddleware } = require("http-proxy-middleware");

app.use(
  ["/api", "/auth/google"],
  createProxyMiddleware({
    target: "http://127.0.0.1:5000", //I used localhost instead but same issue
  })
);

when i start the server i see the message saying proxy is created.

       [HPM] Proxy created: /  -> http://127.0.0.1:5000

but when i visit the localhost:3000/auth/google i get this error

[HPM] Error occurred while trying to proxy request /api from localhost:3000 to http://127.0.0.1:5000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Go to Source
Author: Yilmaz