http-proxy-middleware
http-proxy-middleware copied to clipboard
Fails to proxy from localhost to localhost
trafficstars
Checks
- [X] I understand project setup issues should be asked on StackOverflow or in GitHub Discussions.
- [X] I updated to latest
http-proxy-middleware.
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
We meet this issue also, try to set the target url with '0.0.0.0' or '127.0.0.1' instead of 'localhost'
That was it - thank you.