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

Single use proxy in multi-tenant application

Open thgh opened this issue 1 year ago • 0 comments
trafficstars

Hi, would http-proxy introduce a memory leak if a proxy server was created for each request? At what point should proxy.close() be called? (or it doesn't matter as the server does not listen on a port?)

  // Each request:
  const proxy = createProxyServer({
      target: ...,
      changeOrigin: true,
      followRedirects: false,
    })
    proxy.on('proxyReq', function (proxyReq, req, res, options) {
      ...
      proxyReq.write(request.body)
    })
    proxy.web(request, response, {
      target: ...
    })

thgh avatar Dec 09 '23 07:12 thgh