Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to proxy from localhost to localhost #952

Open
2 tasks done
vadi2 opened this issue Oct 28, 2023 · 2 comments
Open
2 tasks done

Fails to proxy from localhost to localhost #952

vadi2 opened this issue Oct 28, 2023 · 2 comments

Comments

@vadi2
Copy link

vadi2 commented Oct 28, 2023

Checks

Describe the bug (be clear and concise)

Proxying from one localhost port to another localhost port doesn't seem to work.

Step-by-step reproduction instructions

app.use(
    "/api/organization/v1/organization",
    createProxyMiddleware({
      target: "http://localhost:8000",
      changeOrigin: true,
      pathRewrite: {
        "^/api/organization/v1/organization/": "/api/organization/v1/organization/",
      },
    })
  );

Results in:

[HPM] Error occurred while proxying request localhost:3000/api/organization/v1/organization/9db5e2af-81a1-476c-8ddb-45168e02fc6e to http://localhost:8000/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)



### Expected behavior (be clear and concise)

The request is proxied.

### How is http-proxy-middleware used in your project?

```shell
% yarn why http-proxy-middleware
yarn why v1.22.19
[1/4] 🤔  Why do we have the module "http-proxy-middleware"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "http-proxy-middleware"
info Reasons this module exists
   - Specified in "dependencies"
   - Hoisted from "react-scripts#webpack-dev-server#http-proxy-middleware"
info Disk size without dependencies: "156KB"
info Disk size with unique dependencies: "744KB"
info Disk size with transitive dependencies: "8.67MB"
info Number of shared dependencies: 34
✨  Done in 0.39s.

What http-proxy-middleware configuration are you using?

app.use(
    "/api/organization/v1/organization",
    createProxyMiddleware({
      target: "https://fe59-2a02-a210-22c3-ab80-b4a6-fcf4-5617-2ff.ngrok.io",
      changeOrigin: true,
      pathRewrite: {
        "^/api/organization/v1/organization/": "/api/organization/v1/organization/",
      },
    })
  );

What OS/version and node/version are you seeing the problem?

MacOS 13.6

Additional context (optional)

No response

@leolcao
Copy link

leolcao commented Nov 2, 2023

We meet this issue also, try to set the target url with '0.0.0.0' or '127.0.0.1' instead of 'localhost'

@vadi2
Copy link
Author

vadi2 commented Nov 9, 2023

That was it - thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants