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

Can you define multiple routes? #4

Closed
wgorder opened this issue Jul 6, 2015 · 9 comments
Closed

Can you define multiple routes? #4

wgorder opened this issue Jul 6, 2015 · 9 comments

Comments

@wgorder
Copy link

wgorder commented Jul 6, 2015

Wondering if it possible to define multiple routes to be proxied to the same backend server?

@wgorder wgorder changed the title Can you define multiple routes Can you define multiple routes? Jul 6, 2015
@chimurai
Copy link
Owner

chimurai commented Jul 7, 2015

multiple routes are not yet supported.

do you have any thoughts how the function call should look like?

I was thinking something like this:
proxyMiddleware(['/api', '/another_api'], options);

@wgorder
Copy link
Author

wgorder commented Jul 7, 2015

@chimurai that looks good to me, and is what I tried first, just to see if it would work :)

@wgorder
Copy link
Author

wgorder commented Jul 7, 2015

I currently don't have the need to proxy to multiple hosts, however it might be a good idea to support this as well, you would need a way to define a route table.

Examples here, from some others:
https://blog.nodejitsu.com/node-http-proxy-1dot0/
and here:
https://www.npmjs.com/package/httpp-proxy#proxy-requests-using-a-proxytable

@chimurai
Copy link
Owner

chimurai commented Jul 7, 2015

Interesting idea.
Could you give any practical use-cases for this route table option?

I can only think of a vhost-ish setup.

@chimurai
Copy link
Owner

@wgorder
I just pushed a new version to npm with multiple route/path support.
Could you verify the functionality and close this issue?

@EtherealData
Copy link

In the documentation it says we can use multiple contexts.. But passing the array of the two different ones don't work.

In my case, I work with more than one server/API.. Our service calls and servers depend on what module of the application it's on.. In some cases I need to call services across 3 or 4 different contexts..

@EtherealData
Copy link

QUOTING FROM NPMJS PAGE....

var proxyMiddleware = require('http-proxy-middleware');

var proxy = proxyMiddleware('/api', {target: 'http://www.example.org'});
// **/ _____________________________**_/
// | |
// context options

// 'proxy' is now ready to be used in a server.

context: matches provided context against request-urls' path. Matching requests will be proxied to the target host. Example: '/api' or ['/api', '/ajax']

@chimurai
Copy link
Owner

@giohperez could you provide the depencies/devdependencies in your package.json?
and also how you configured the proxy middleware.

I'm suspecting you are using an older version. multiple paths support is introduced in v0.2.0

@chimurai
Copy link
Owner

Closing this issue.
Please leave a reply when you're experiencing issues with multiple contexts.

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

No branches or pull requests

3 participants