You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request terminates in middleware. There is however an option "option.onProxyRes" that allows you to further handle the request as you wish in the onProxyRes handler.
However, this handler only takes proxyRes, req, res as args. How may i then call the next middleware in my stack?
Excerpt from readme:
function onProxyRes(proxyRes, req, res) {
proxyRes.headers['x-added'] = 'foobar'; // add new header to response
delete proxyRes.headers['x-removed']; // remove header from response
}
Fairly new to express so please excuse me if this is a silly question..
Thanks!
The text was updated successfully, but these errors were encountered:
Request terminates in proxy middleware. "after" is therefore never logged.
Example scenario
Say you have a middleware stack that looks like this:
auth
request validation
proxy
here i might add additional event handlers to format my request before going out and perhaps the response as well
response validation
other middleware
some more middleware
return response to client
The current specification terminates the request once a response has been returned from proxy. Meaning that steps 4-7 are effectively ignored. From what i have read there is seemingly no way to pass the response to the next middleware.
What would be the correct approach to a problem like this?
Possible solutions
Move remaining middleware into the onProxyRes event handler.
Requires a fair bit of hackery as the subsequent middlewares are not called as expexted (via next()). Not even sure that this would work
Create a completely independent express instance which only handles the proxying. Wrap this in its own middleware and append to the "outer" express instance.
Could seemingly work. Might have to do some intelligent merging of responses.
I will try to solve this using the latter solution.
Request terminates in middleware. There is however an option "option.onProxyRes" that allows you to further handle the request as you wish in the onProxyRes handler.
However, this handler only takes proxyRes, req, res as args. How may i then call the next middleware in my stack?
Excerpt from readme:
Fairly new to express so please excuse me if this is a silly question..
Thanks!
The text was updated successfully, but these errors were encountered: