Firstly, thanks for this library, it's got a great api and works well when it's used as a single proxy middleware.
Problem
When registering multiple proxy middleware, the event listeners are only set up for the first proxy but not the subsequent proxies. This should either be supported or there should be a disclaimer on the README to detail that it's not supported. It's more of a bug because the proxy works fine it's just the events that don't get triggered.
The problem is essentially here:
// llne 20
let eventRegistered = false
// line 58
if (events && typeof events === 'object' && !eventRegistered) {
Recreate
function logFirstRequest() {
console.log('gets called')
}
function logSecondRequest() {
console.log('doesnt get called')
}
// First middleware
app.use(proxy('/first-test', {
target: 'http://localhost:5000',
events: {
proxyRes: logFirstRequest,
},
})
)
// Second middleware
app.use(proxy('second-test', {
target: 'http://localhost:4999',
events: {
proxyRes: logSecondRequest,
},
})
)
I've got a fix but will require quite a big change in functionality, if this is something that you'd like fixed?
Firstly, thanks for this library, it's got a great api and works well when it's used as a single proxy middleware.
Problem
When registering multiple proxy middleware, the event listeners are only set up for the first proxy but not the subsequent proxies. This should either be supported or there should be a disclaimer on the README to detail that it's not supported. It's more of a bug because the proxy works fine it's just the events that don't get triggered.
The problem is essentially here:
Recreate
I've got a fix but will require quite a big change in functionality, if this is something that you'd like fixed?