Search code examples
angularentity-framework.net-coreazure-signalr

Facing cors issue after making successful api call in abp application


Access to XMLHttpRequest at 'serversiteurl//api/services/app/QklyProcessEngine/CallProcess' from origin 'clientsiteurl' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Getting this above error, after making a api call from client and after 3 mins i'm getting the errors, every time i call that specific api. I'm so confused to conclude whether it's an api error or cors error.

NOTE : My cors configuration is perfect.

Every time I get cors issue, i get this below server error.

System.Threading.Tasks.TaskCanceledException: A task was canceled. 
    at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.CreateSavepointAsync(String name, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) 
    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) 
    at Qkly.EntityFrameworkCore.QklyDbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in D:\a\Quickly-application\Quickly-application\src\Qkly.EntityFrameworkCore\EntityFrameworkCore\QklyDbContext.cs:line 6200 
    at Abp.EntityFramework...

Solution

  • Check server response in Developer Console in your browser - I guess you'll see 500 status code and ServerError page from your server.

    And usually these error pages do not include any CORS headers or other such things.

    So, you have server API error. Inability of client JS to correctly read this error (due to CORS) is secondary.