stegano / next-http-proxy-middleware

HTTP Proxy middleware available in API Middleware provided by Next.js.
236 stars 19 forks source link

Fix event listener on "proxyReq" #77

Closed casheeeewnuts closed 1 year ago

casheeeewnuts commented 2 years ago

Current code has a problem that calling proxyReq.end() method don't wait proxyReq.write(req.body). To fix, proxyReq.end() must be called in callback that be passed second argument with proxyReq.write().

Another solution is piping the original request to proxy with req.pipe(). By use it, dont need to use JSON.stringify() to serialize request body. So, performance improvement expected.

And more type-safe.