http-party/node-http-proxy

Single use proxy in multi-tenant application

thgh opened this issue · 0 comments

thgh commented

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: ...
    })