Comments (9)
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.
@chimurai that looks good to me, and is what I tried first, just to see if it would work :)
from http-proxy-middleware.
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.
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.
@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.
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.
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.
@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.
Closing this issue.
Please leave a reply when you're experiencing issues with multiple contexts.
from http-proxy-middleware.
Related Issues (20)
- Filter example in README wrong. HOT 1
- Cannot override options in the `onProxyReq` method. HOT 1
- websocket messages interception & manipulation
- Intercept HTTP(s) calls and modify request "paths" on the fly HOT 1
- Issue obtaining body and updating it as part of proxy HOT 3
- Proxy request fails due to bodyParser HOT 1
- Fails to proxy from localhost to localhost HOT 2
- Too many subscriptions to Server.close event cause a OOM? HOT 4
- TS type compatibility HOT 4
- ERR_HTTP_HEADERS_SENT from onProxyReq with https-proxy-agent HOT 2
- Proxy to another proxy HOT 1
- Security Vulnerability in Dependency | follow-redirects HOT 2
- "Invalid context" error message is unhelpful when mixing paths with globs HOT 1
- Release plan for v3.0.0 HOT 1
- Response interceptor copyHeaders logic only removes first character of cookie domain because of non-greedy regex
- TypeError: (options.buffer || req).pipe is not a function HOT 1
- Allow custom Http Method like LIST HOT 3
- SSE close connection issue with proxy HOT 3
- V3: base path not stripped from WebSocket upgrade requests HOT 2
- SSL Error in when Upgrading from node 16 to 18 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-proxy-middleware.