Comments (3)
Hello @feegloo,
I have a workaround, set different target in url path:
const Koa = require('koa');
const proxy = require('koa-proxies');
const app = new Koa();
const targets = {
bar: 'http://localhost:3000/',
baz: 'http://localhost:3001/'
};
app.use(proxy('/proxy/:target/', function(params) {
return {
target: targets[params.target] || 'http://localhost:8080',
rewrite: p => p.replace(/^\/proxy\/\w+\//, '/'),
changeOrigin: true,
logs: true
};
}));
app.listen(8080);
then we can call:
Refs: https://github.com/vagusX/koa-proxies/blob/master/index.js#L33
because the options can be a function.
from koa-proxies.
Hello @wuliupo, @feegloo,
in our case it is also not possible to distinguish the target by URL parameters.
For out local environment we use the referer header to route to either local server or remote server.
Simply passing the context to the mentioned function a1d3e19 allows to create dynamic target based on the context content.
I created pull request #52 for that.
from koa-proxies.
The issue is taking too long I have to fork and rewrite it for supporting router config https://github.com/luxueyan/koa-proxies
from koa-proxies.
Related Issues (20)
- The Promise returned by this middleware never get resolved HOT 5
- Customize logger HOT 2
- Version 10 of node.js has been released HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 36
- An in-range update of chai-http is breaking the build 🚨 HOT 4
- The automated release is failing 🚨
- Inspect proxied response body?
- PATCH method doesn't proxy request body HOT 1
- Release the new version HOT 3
- Typings support requested HOT 1
- Incorrect URL in logging when using target path HOT 3
- koa-proxies should be In front of the koa-bodyparser.
- options.events is missing in .d.ts HOT 1
- proxy option type error HOT 2
- proxy does't carry cookie HOT 2
- Doesn't support event listening for multiple proxies
- ERR_TLS_CERT_ALTNAME_INVALID from proxy.web()
- IBaseKoaProxiesOptions Should Extend http-proxy Server.ServerOptions
- Error callback blocks all custom error handlers
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 koa-proxies.