'Jquery Ajax No 'Access-Control-Allow-Origin' header is present on the requested resource

I have been struggling with this day for days now, not sure where the problem is. Running long request makes the page timeout and I get this return error:

from origin 'xxxxxxx' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. after 2 mins

Front end is jQuery/Ajax that makes a POST request to the backend running on nodejs Firebase. Everything works if the request is less than 2mins. This issue applies to POST with large CSV file, or DELETE that takes a while from the backend.

I have tried:

  1. Adding 'Access-Control-Allow-Origin' to Ajax, no luck
  2. Modified sudo vi /etc/apache2/apache2.conf KeepAlive, no luck
  3. Added "key" : "Access-Control-Allow-Origin", to firebase config header file, no luck

How else can I run a loop that takes times while keeping the page alive for like 3-5 mins?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source