GithubHelp home page GithubHelp logo

Comments (9)

chimurai avatar chimurai commented on May 21, 2024

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);

from http-proxy-middleware.

wgorder avatar wgorder commented on May 21, 2024

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

from http-proxy-middleware.

wgorder avatar wgorder commented on May 21, 2024

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

from http-proxy-middleware.

chimurai avatar chimurai commented on May 21, 2024

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

I can only think of a vhost-ish setup.

from http-proxy-middleware.

chimurai avatar chimurai commented on May 21, 2024

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

from http-proxy-middleware.

EtherealData avatar EtherealData commented on May 21, 2024

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..

from http-proxy-middleware.

EtherealData avatar EtherealData commented on May 21, 2024

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']

from http-proxy-middleware.

chimurai avatar chimurai commented on May 21, 2024

@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

from http-proxy-middleware.

chimurai avatar chimurai commented on May 21, 2024

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

from http-proxy-middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.