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

Only set content-length when request is not a GET request

Open fetimo opened this issue 9 years ago • 1 comments

Hi,

An app I'm trying to interact with is throwing a 400 error as this library will stringify an empty body ({}) resulting in a content length of 2, even though the content length of the GET request is 0.

I've submitted a PR that only sets the content-length header if the request is not a GET, I'm open to suggestions for other approaches though.

fetimo avatar Jan 10 '17 16:01 fetimo

AWS CloudFront doesn't like GET requests with a body.

This fixed it for us:

proxyReqBodyDecorator: (bodyContent, srcReq) => {
  if (srcReq.method === 'GET') return "";
  return bodyContent;
},

Related: #475

zavan avatar Oct 30 '24 14:10 zavan