chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.68k stars 826 forks source link

http-proxy-middleware.ts Return promise to wait end of connection #869

Closed desfun closed 4 months ago

desfun commented 1 year ago

It allows koajs handle http-proxy-middleware, awaiting end of transaction from proxy, if you don't handle it, response will be emitted before end of proxy request.

Description

Allow handle propperly end of remote connection before emit response to client.

Motivation and Context

Koajs compability

How has this been tested?

const app = new koa(); app.use(async ({req,res},next)=>{ const Proxy = createProxyMiddleware(options); await Proxy(req,res,next); }});

Types of changes

Checklist:

chimurai commented 4 months ago

Doesn't look like valid implementation.

image

Runtime error:

image

Feel free to update PR if working implementation + test can be provided