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

Allow proxy to maintain the original target path #693

Merged
merged 2 commits into from
Sep 8, 2014
Merged

Allow proxy to maintain the original target path #693

merged 2 commits into from
Sep 8, 2014

Conversation

EndangeredMassa
Copy link
Contributor

This completes the work started in: #645

  • Fixed tests
  • Added a test for the path behavior

This fix considers the actual target path again (which has been ignored).
@EndangeredMassa EndangeredMassa mentioned this pull request Sep 8, 2014
@jcrugzz
Copy link
Contributor

jcrugzz commented Sep 8, 2014

@EndangeredMassa One thing I would do though is also support forward requests. Follow the convention we use of options[forward || 'target']. Otherwise this is great, thanks for the effort!

@EndangeredMassa
Copy link
Contributor Author

I updated it, but I'm not really clear on how forward is supposed to be used here. Let me know if I need to tweak it.

@jcrugzz
Copy link
Contributor

jcrugzz commented Sep 8, 2014

@EndangeredMassa its passed in as a variable so it does an undefined check relying on the || operator to default to 'target' if its not a forward request. See here.

And this looks great, thanks!

jcrugzz added a commit that referenced this pull request Sep 8, 2014
Allow proxy to maintain the original target path
@jcrugzz jcrugzz merged commit 814fbd2 into http-party:master Sep 8, 2014
@EndangeredMassa EndangeredMassa deleted the fix-path branch September 8, 2014 22:27
@jcrugzz
Copy link
Contributor

jcrugzz commented Sep 10, 2014

Im realizing that this shouldnt necessarily be default behavior. This should be configured in some way. @EndangeredMassa naming suggestions? Seems like a boolean option is the best way to deal with this.

@EndangeredMassa
Copy link
Contributor Author

Hrm. I expect this behavior to be default. In my mind, adding a url that includes a path in the target means that I want to use that full url, not just the host, port, and protocol.

@jcrugzz
Copy link
Contributor

jcrugzz commented Sep 10, 2014

@EndangeredMassa Yea that's understandable. Im guessing our case at nodejitsu is the special case as it is more specific to how couchdb interprets the request. We currently proxy to couchdb instances with smart-private-npm by setting the host to registry.nodejitsu.com for example and the URL is https://myCouchdb.com/registry. This change currently breaks the way we have been proxying. Ill think of a good option for this I suppose as that seems like it will be what is necessary.

@manast
Copy link

manast commented Nov 11, 2014

It should not be default unless a major version update, since this breaks backwards compatibility... we ended with such a problem in redbird, that already appends the target path if necessary: https://github.com/OptimalBits/redbird

@indexzero
Copy link
Contributor

@manast it does not break backwards compatibility. It introduces a new feature that allows for the path to be part of the target when creating HttpProxy instances.

@manast
Copy link

manast commented Nov 11, 2014

@indexzero in my opinion that is not really the case, because even if not supported before, if you happen to have a path in the target, the new behaviour would break things. It is a bit in the grey zone, but I think the safest bet would have been to have it disabled by default, users wanting to use the new feature would have been forced to enable it manually. For instance, before this feature existed, many people created its own third party code for adding it, this code usually left the target with the complete path since it was not necessary to parse it just to remove it.
Anyway, it is too late now for anything so pointless discussion other than flagging that since http-proxy is so critical in many deployments, maintaining backwards compatibility should be taking very seriously.

@indexzero
Copy link
Contributor

We do take backwards compatibility very seriously, and I will say it again: this is backwards compatible. Objects that node-http-proxy accepts should have only the properties that node-http-proxy expects and should be expected to be mutated by node-http-proxy. If a user was passing in superfluous properties that are now meaningful then they were using the library incorrectly to begin with.

If you would like to update the documentation about this point I would greatly appreciate it.

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

Successfully merging this pull request may close these issues.

5 participants