I have hosted aspnetboilerplate asp.net core application as App service on azure and Angular application on Azure VM.
When Angular application tries to request asp.net core application, CORS error occures for AbpUserConfiguration/GetAll.
Surprisingly this works well when I run angular application from local workstation. This issue only occurs when I try to run angular application from Azure VM.
ConfigureServices function has correct sequence of CORS and MVC. Also tried with specific Origin and with AllowCredentials, but no luck.
//Configure CORS for angular2 UI
services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, p =>
{
p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
});
});
//MVC
services.AddMvc(options =>
{
options.Filters.Add(new CorsAuthorizationFilterFactory(DefaultCorsPolicyName));
});
Though we set AllowAnyOrigin and AllowAnyMethod the network request shows it as below
Access-Control-Request-Headers:abp.tenantid,authorization,content-type
Access-Control-Request-Method:GET
All responses are greatly appreciated!
On the Azure server webapp you must also enable CORS. I think you will need to add the address of the VM and not just the client site.