1

My react app uses axios for POST-requests to the server. When the server needs more than 2min for answering the request is called again. But only in FF, Chrome, NOT in IE11. I don't think that this is a Cross-Origin Resource Sharing (CORS) preflight issue, because this happens only for requests with long response times.

Client:
    axios.post("host:port/context", {
      params,
      headers: {
        "Content-Type": "text/plain"
      }
    });

Server:
const server = http.createServer();
server.listen(4000);
server.setTimeout(240000);
server.keepAliveTimeout = 240000;

A Router from express is also used on the server:
const router = new Router();
router.post(
  "/context",
  handlingOfRequest()
);
dev7005
  • 11
  • 3
  • it sounds like an issue with browser's native ajax call timeout value. You might want to check XMLHttpRequest.timeout – Doğancan Arabacı May 20 '19 at 14:50
  • The try by making the ajax call with XHR and timeout (and not via axios) ends with the same result. The request is called twice. – dev7005 May 21 '19 at 10:06
  • const xhr = new XMLHttpRequest(); xhr.open("POST", url, true); xhr.setRequestHeader("Content-type", "text/plain"); xhr.timeout = 480000; xhr.send(JSON.stringify(params)); xhr.onload = function(e) { if (xhr.readyState === 4) { console.log(e); if (xhr.status === 200) { console.log(e); } else { console.error(xhr.statusText); } } }; xhr.onerror = function(e) { console.error(xhr.statusText); }; – dev7005 May 21 '19 at 10:13
  • It's not an OPTIONS request right? It's POST – Doğancan Arabacı May 21 '19 at 10:45
  • Yes it's a POST ... – dev7005 May 21 '19 at 11:16
  • 1
    dev7005 Have you ever found a solution to this? Having the same problem – tim Mar 25 '20 at 20:24

0 Answers0