node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

selfHandleResponse should not require target

Open strowk opened this issue 4 years ago • 1 comments
trafficstars

I configure proxy setting selfHandleResponse option to true and pass onProxyRes with appropriate function. I expect that target will not be required , because docs state

if set to true, none of the webOutgoing passes are called

However, what I notice instead is that

  1. if target not passed I get error: Missing "target" option. Example: {target: "http://www.example.org"}
  2. if target passed as http://localhost:9999 , but nothing is listening on 9999 I get 504
  3. if target passed and call there is possible, I get what I returned in onProxyRes; no matter what is served on target (as expected to happen, except that call to target should not be happening at all)

This leads me to conclusion that target is used to make outgoing request and if nothing backs that request - proxy fails with timeout. This is not expected behavior. It is expected that no outgoing requests are called and proxy simply returns what onProxyRes has given back.

strowk avatar Jul 16 '21 12:07 strowk

I am just learning about this library myself but as I understand it selfHandleResponse option will not prevent the request to the target but rather prevent the targets response from being returned to the original client. This gives you the opportunity to return a custom response.

DarrylMcoder avatar Dec 24 '21 15:12 DarrylMcoder