title: How to proxy data without transfer-encoding: chunked?
body: <p>I have an express.js-based proxy that I use to proxy various separate apps deployed via Serverless and AWS Lambda into the same domain:</p>
  <pre><code>const serverless = require('serverless-http');
  const httpProxy = require('http-proxy');
  const express = require('express');
  
  
  const app = express();
  
  const proxy = httpProxy.createProxyServer();
  
  proxy.on('proxyReq', (proxyReq) =&gt; {
    proxyReq.setHeader('X-Projects-Router-Proxy-Out', true);
  });
  
  app.get(['/:project', '/:project/*'], (req, res) =&gt; {
    const { project } = req.params;
    const rest = req.params[0];
    const url = `https://${project}.${process.env.DEPLOY_STAGE}.example.com/${project}`;
    req.url = rest ? `/${rest}` : '';
  
    proxy.web(req, res, {
      target: url,
      xfwd: false,
      toProxy: true,
      changeOrigin: true,
      secure: true,
    });
  });
  
  module.exports.handler = serverless(app);
  </code></pre>
  <p>This works very well for most things, but I'm now having trouble. One of the projects I'm proxying is a next.js app, and the <code>_next</code> directory's assets all return a 502 Bad Gateway error because chunked encoding is not supported by AWS API Gateway (which I'm using to handle all the requests). According to some <a href="https://github.com/dougmoscrop/serverless-http/issues/142" rel="noreferrer">google</a> <a href="https://github.com/awslabs/aws-serverless-express/blob/ecdafec8f05eecc97791930b26d93e63a84e6188/src/index.js#L80-L82" rel="noreferrer">results</a>, I ought to just be able to removed the <code>transfer-encoding: chunked</code> header.</p>
  <p>Which would be fine, except there <em>is</em> no transfer-encoding header being sent on these assets, so removing it does nothing to fix the problem. I think there is <em>also</em> no content-length header being sent, so it assumes <code>chunked</code> by default. How do I add a content-length header? Is there another way of getting around this problem?</p>