chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.68k stars 826 forks source link

Response object access in pathRewrite (for locals) #854

Open AllanJard opened 1 year ago

AllanJard commented 1 year ago

Describe the feature you'd love to see

I'm looking to access a res.local. property inside my pathRewrite custom function, but it isn't passed in - just the path and the request object.

I've looked around and I don't immediately see anyone else asking about this, so perhaps it is a little unusual, but the res object is available where prepareProxyRequest is called and it could be passed down the chain like res is perhaps?

Additional context (optional)

No response

perry-mitchell commented 3 months ago

This should also be present in router imo. All handlers could easily have res for res.locals access as this is far better for adding custom properties than placing them on the req object itself. Better for types too.