angularasp.net-coreaspnetboilerplate

Intermittent CORS policy issue with ABP (AspNet Boilerplate) API


ASP.NET Zero (.Net Core v2 + Angular v5)

AbpUserConfiguration/GetAll breaking sometimes, after serving few requests it start generating cross domain issue other times it works perfectly.

Following is the error.

Access to XMLHttpRequest at 'http://localhost:22743/AbpUserConfiguration/GetAll' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

GET http://localhost:22743/AbpUserConfiguration/GetAll net::ERR_FAILED


Solution

    1. The ASP.NET Zero have configured CORS Origins allowed-list properly already, just ensure that you put the right value on the App:CorsOrigins setting in appsettings.json file.
    {
      ...
      "App": {    
        "ServerRootAddress": "http://localhost:22743/",
        "ClientRootAddress": "http://localhost:4200/",
        "CorsOrigins": "http://localhost:4200",
        ...
      },
      ...
    }
    
    1. Sometimes, the error message is misleading. It show this error because some errors occur on server side. Just investigate the log file or debug and fix it, then this message will gone.