-
Notifications
You must be signed in to change notification settings - Fork 854
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
[Bug] not working at node 17 #705
Comments
BTW, working great on node 16.x |
This example works in node v17.4.0. https://github.com/chimurai/http-proxy-middleware/blob/master/examples/express/index.js Just clone the repo and run Can you provide a minimal reproducible project with the error? Without one there is little to investigate. |
This could be caused by: nodejs/node#40702. I don’t understand the DNS stuff though, so I’m not sure about anything. This seems to reproduce the problem: app.use(
"/api",
proxy.createProxyMiddleware({
target: "http://localhost:3000",
})
); I think the reason the linked example works is because it doesn’t use Note:
EDIT: It seems like if I run the official Node.js HTTP hello world example on port 3000, EDIT2: Figured it out. I was running the Suave server explicitly on https://nodejs.org/api/net.html#serverlistenport-host-backlog-callback
When setting const http = require('http');
const requestListener = function (req, res) {
res.writeHead(200);
res.end('Hello, World!');
}
const server = http.createServer(requestListener);
server.listen(3000, '0.0.0.0'); Sorry, about the confusion – this is not my area of expertise. |
You shouldn't be using |
Thank you, this was the issue for me on Node 17 and 18, while the pattern was working on previous node versions |
@treysis |
@krpeacock @davidmeirlevy |
Support for node17 will stop in june 2022... Not sure if it worth the effort to investigate the issue for node 17. Node 18 just got released: https://nodejs.org/en/blog/announcements/v18-release-announce/ Do you have the same issue when you're using node 18? |
@chimurai I tested with Node.js 18.1.0 now, and yes, I have the same issue with Node.js 18. |
Looks like Node v17+ changed to way
Can you try replacing There is a --dns-result-order=ipv4first https://www.redhat.com/en/blog/welcome-nodejs-18
|
Yes, partly. It just doesn't reorder the DNS results anymore. That's what we said all the time. The lookup works the same as before. Don't use the DNS flag as it will prevent IPv6-connectivity. Just instead of localhost use 127.0.0.1. |
@chimurai the way we're using /**
* Workaround for http-proxy-middleware DNS lookup issue with Nodejs 17+
* [See here for details]{@link https://github.com/chimurai/http-proxy-middleware/issues/705#issuecomment-1126925635}
**/
target: target.replace('http://localhost', 'http://127.0.0.1'), Any plans to fix this internally in the |
@raspy8766 that's a neat solution but probably for most cases - your solution is excellent. I think I will close this bug since it's actually a bug mostly in implementing dev environments with node, and not specifically for this middleware. |
Indeed not a bug in http-proxy-middleware but a configuration issue when upgrading to node 17/18. |
@chimurai Is it worth updating README.md (and examples) to use Tricky stuff, it’s all about whether the server I proxy to accepts IPv4, IPv6 or both. Here are some more details: nodejs/node#40702 (comment) |
Definitely makes sense to update the documentation with a note to new the Node behaviour in node 17+. 👍 |
for me, node 17 doesn't work because somehow the example code simply doesn't create the proxy from the right base url, it keeps using / to proxy for some reason. Using express, node 17, and used the example code provided. The result is simply proxy didn't work. I guess I have to use another library, was expecting this work out of box but somehow it just doesn't work no matter what I do. |
This kind of bugs, have headache symptoms. 😄 |
You can't combine IP with subdomain |
@Chukwu3meka But |
Something like dev.127.0.0.1:3000 would not work, unlike dev.localhost:3000 |
@Chukwu3meka I understand. Is there any reason for using subdomains of localhost? |
Please use the Discussions for project configuration issues. Thanks. |
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
use the library to proxy into another service.
not working when upgraded to node 17.
Step-by-step reproduction instructions
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Additional context (optional)
No response
The text was updated successfully, but these errors were encountered: