-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Some sites break because of req.url being absolute #529
Comments
Here is my changeset to my front-end dev tool using node-http-proxy which fixes this assumption. |
This is also the cause of incompatibility with socket.io. |
Add "all express sites using the express.sessions middleware," also known as "all sites using the connect sessions middleware." if (0 != req.originalUrl.indexOf(cookie.path || '/')) return next(); That is trying to detect a leading / in the default configuration. It'll never happen with an absolute URL. There are just too many commonly used frameworks, and therefore sites, that don't work with this behavior. |
@fabiosantoscode Thanks for that simple solution, it should have occurred to me since I'm doing custom proxying with proxy.web too. Here's a better regexp that should not experience false positives: req.url = req.url.replace(/^\w+://.*?//, '/'); |
@boutell and @fabiosantoscode if you haven't already, check out the |
Jarrett, I'm experiencing this with the caronte branch. It is a serious On Tue, Dec 10, 2013 at 12:36 AM, Jarrett Cruger
Tom Boutell |
Although it is indeed serious, I don't think it is trivial to fix. After I will try out the caronte branch. |
That is true, there needs to be appropriate behavior based on whether this Trivial or not though, I don't think it makes sense to ship a "1.0" version On Tue, Dec 10, 2013 at 7:28 AM, Fábio Santos notifications@github.comwrote:
Tom Boutell |
Smallest reproducible case: https://gist.github.com/fabiosantoscode/349a8d29d3bdf109c78c It's unfortunate that the API will be one option more complicated just because there's too much stuff not implementing this correctly. We should report this problem when we see it in the real world. |
Real world cases cited here so far: Wordpress This is a duplicate of #416 which cites pages on dailymotion. Re: the spec, that bit says in full: "To allow for transition to absoluteURIs in all requests in future versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI form in requests, even though HTTP/1.1 clients will only generate them in requests to proxies." Emphasis on that last bit. The servers that don't like the absolute URI are most in the wrong here, but we're not doing all that hot either because we're generating absolute URIs when not talking to (another) proxy. |
apologies for the delay, should be fixed in 9e74a63 @fabiosantoscode i used the test case you provided and now it's correctly sending "/" instead of the full path :) |
With this closed, do we need to open a new issue on support for being downstream from another proxy? That has the opposite issue: an absolute URL is required. |
i would be happy to accept a pull request regarding that, or a test case which outlines the issue :) |
It doesn't affect me at all personally, but it seemed only honest to point On Wed, Dec 18, 2013 at 10:54 AM, yawnt notifications@github.com wrote:
Tom Boutell |
According to the HTTP standard, a request's URI (the second field in the first line of an HTTP request, after the verb, and which gets into req.url) may be relative or absolute.
A request to a proxy must always have an absolute URI, and indeed when we receive a request, req.url is always absolute. We just forward the request in proxyRequest and copy the URI into the new request.
The receiving end of our new request will in turn get an absolute URI. This behaviour, however standard, is breaking some sites which naively expect the path to be relative to the hostname (starting with a "/"). They are wrong, but still node-http-proxy could be "fixed" so as to not break this assumption of theirs.
By placing "req.url = req.url.replace(/.?://.?//, '/')" (an ugly regexp, granted) before calling proxyRequest I was able to conform to the naiveté of Wordpress and other stuff which is out there being used and does not implement the standard.
Thanks for building this nice, flexible proxy.
The text was updated successfully, but these errors were encountered: