In my angular application
, I'm calling an API that takes more than 2 minutes to respond but after 2 minutes, angular throws following error;
Access to XMLHttpRequest from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Backend returned code 0, body was: [object ProgressEvent]
Failed to load resource: net::ERR_FAILED
I've tried every possible solution that I found on internet and SO like;
Adding timeout on service call;
return this.httpClient.post<ViewModelResponse>(this.baseUrl + this._getMetaDataUrl, { headers: this.configurations.getHeaderWithAuth() }).timeout(300000);
Adding timeout with pipe
return this.httpClient.post<ViewModelResponse>(this.baseUrl + this._getMetaDataUrl, { headers: this.configurations.getHeaderWithAuth() }).pipe(timeout(300000));
Implements HttpInterceptor followed this answer
Added timeout in headers
"timeout": ${300000}
Increased IIS server timeout to 20 minutes..
People also suggested changes in Proxy file but I don't have any proxy file..
But nothing worked for me.. all these solutions failed once the API response exceeds 2 minutes. I'm using dotnet core
at backend and it returns proper response everytime.
In case of Pipe(timeout()), call was at backend but angular throws error that response is null
Any kind of help will be appreciated.