TTFB on whatwg-fetch request from NodeJS app is over 15 seconds every time. What am I doing wrong?

March 13, 2018 926 views
DigitalOcean Node.js MySQL PHP Ubuntu 16.04

I am making a whatwg-fetch request from my React application served up at like so:

    fetch('', {
      credentials: 'include',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      body: JSON.stringify({
        SearchValue: this.props.SearchValue,
        SearchOption: this.props.SearchOption,
    .then(response => response.json())
    .then(data => {

On the other end (at I have this:

header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: content-type");
header("Access-Control-Max-Age: 86400");

/* Prepared Statement (not very complicated, returns 5 results) */

For some reason the server takes 15 seconds to respond to my fetch request. It takes 15 seconds (most of the time) just to get the first byte back from the responding server. What am I doing wrong? How do I use fetch to get data from my database in JSON format?

1 comment
  • Are you seeing the same behavior when accessing directly?

Be the first one to answer this question.