Proxied requests other than GET are hanging with NestJS and http-proxy-middleware

I've finally figured out the problem. It seems to be related to the body parser. If I change the API Gateway to turn off the body parser the request is forwarded successfully.

So the solution was to replace

const app = await NestFactory.create(AppModule);

with

const app = await NestFactory.create(AppModule, { bodyParser: false });

I've also created a branch issue-fixed in the Git repo where the fix is implemented.


Set bodyParser: false when create Nest Application just fix the issue for endpoint we're proxying, it'll cause other endpoints (Eg: JWT localAuth) to be failed as they need body to be parsed.

The solution is to create a middleware as describe in this anwser to disable bodyParser for endpoints you're proxying and enable it for the rest.