Created by: LiranBri
Following issues https://github.com/http-party/node-http-proxy/issues/490 and https://github.com/http-party/node-http-proxy/issues/1403, currently the library does not support async handler for the proxyReqWs
event for modifying the request before proxying it forward.
This suggested PR solved the problem, without breaking backward compatibility, by introducing a new argument asyncContext
which is used as follows:
onProxyReqWs: (proxyReq, req, socket, options, head, asyncContext) =>
asyncContext(async () => {
// code ...
const result = await anyAsyncOperation()
// code ...
proxyReq.setHeader('key', result)
}),