title: Fetch times out after 2 minutes
body: <p><strong>Project Description</strong></p>
  <p>I'm working on a NodeJS/Express application that, on loading the home page, uses Fetch to call a route that makes an API request. The data retrieved from the API request is returned to the client into a dropdown.</p>
  <p><strong>Problem</strong></p>
  <p>The API request often takes longer than 2 minutes to return a response, which causes Fetch to timeout with a 504 Gateway Timeout. It's my understanding the default timeout for Express is 2 minutes, so I've tried numerous ways to increase this timeout but have had no luck. <strong>It may be worth noting that I only get these timeout errors when testing the deployed code. When I test by running the code locally, I get no errors, and the 2 minute timeout does not appear to exist.</strong> Enforcing a timeout using some of the attempts below would cause a timeout when running locally.</p>
  <p><strong>Fix Attempts</strong></p>
  <ol>
  <li><p>Using the Express connect-timeout middleware as described <a href="http://expressjs.com/en/resources/middleware/timeout.html" rel="nofollow noreferrer">here</a>. I tested as a top-level middleware, and within the route itself.</p>
  </li>
  <li><p>Setting the server timeout after the app.listen() function:</p>
  <pre><code> var server = app.listen(port, () =&gt; console.log(`Listening on port ${port}...`));
   server.setTimeout(3 * 60 * 1000);
  </code></pre>
  </li>
  <li><p>Setting the keepAliveTimeout and headersTimeout after the app.listen() function:</p>
  <pre><code> var server = app.listen(port, () =&gt; console.log(`Listening on port ${port}...`));
   server.keepAliveTimeout = 30000; 
   server.headersTimeout = 31000;
  </code></pre>
  </li>
  <li><p>Setting the request timeout within the route called from Fetch:</p>
  <pre><code> router.post('/example', function (req, res) {
       req.setTimeout(3 * 60 * 1000);
       // Call function that makes API request
       return res.send(api_response_data);
   });
  </code></pre>
  </li>
  </ol>
  <p><strong>Stack Overflow Threads Used</strong></p>
  <p><a href="https://stackoverflow.com/questions/12651466/how-to-set-the-http-keep-alive-timeout-in-a-nodejs-server">How to set the HTTP Keep-Alive timeout in a nodejs server</a></p>
  <p><a href="https://stackoverflow.com/questions/23925284/how-to-modify-the-nodejs-request-default-timeout-time">How to modify the nodejs request default timeout time?</a></p>
  <p><a href="https://stackoverflow.com/questions/55364401/express-js-connect-timeout-vs-server-timeout">Express.js connect timeout vs server timeout</a></p>
  <p><a href="https://stackoverflow.com/questions/21708208/express-js-response-timeout">Express.js Response Timeout</a></p>
  <p><a href="https://stackoverflow.com/questions/7222467/express-js-http-request-timeout">Express.js HTTP request timeout</a></p>
  <p>Most of the attempts listed above are reflected in these threads; however, I tried almost all suggestions found these threads as well.</p>