Hi,
When deploying the angular 4 application on one port and the .net core in another there is a call from the browser made to the endpoint /AbpUserConfiguration/GetAll with the OPTIONS method. This call fails from the angular application but it is successful for a GET request from a browser.
The angular app logs the following error: OPTIONS <a class="postlink" href="http://x.x.x.x:22741/AbpUserConfiguration/GetAll">http://x.x.x.x:22741/AbpUserConfiguration/GetAll</a> net::ERR_EMPTY_RESPONSE
The asp.net core app logs the following:
Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL6E2JO8MMJV" started.
Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL6E2JO8MMJR" stopped.
Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL6E2JO8MMJU" disconnecting.
Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL6E2JO8MMJU" sending FIN.
Microsoft.AspNetCore.Server.Kestrel - Connection id "0HL6E2JO8MMJU" sent FIN with status "0".
I think this is a Cors issue but I do not know how to solve it. I have tried the following two configurations but neither seems to work.
//Configure CORS for angular2 UI
services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
{
//App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma.
builder
//.WithOrigins(_appConfiguration["App:CorsOrigins"].Split(",", StringSplitOptions.RemoveEmptyEntries).Select(o => o.RemovePostFix("/")).ToArray())
.AllowAnyOrigin() //TODO: Will be replaced by above when Microsoft releases microsoft.aspnetcore.cors 2.0 - https://github.com/aspnet/CORS/pull/94
.AllowAnyHeader()
.WithMethods(new string[] {"OPTIONS","GET","POST","PUT","DELETE", "HEAD" });
});
});
//Configure CORS for angular2 UI
services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
{
//App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma.
builder
//.WithOrigins(_appConfiguration["App:CorsOrigins"].Split(",", StringSplitOptions.RemoveEmptyEntries).Select(o => o.RemovePostFix("/")).ToArray())
.AllowAnyOrigin() //TODO: Will be replaced by above when Microsoft releases microsoft.aspnetcore.cors 2.0 - https://github.com/aspnet/CORS/pull/94
.AllowAnyHeader()
.AllowAnyMethod();
});
});
1 Answer(s)
-
0
Hi,
Have you configured CorsOrigins value in appsettings.json in your host application ? You can check it here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/appsettings.json#L16">https://github.com/aspnetzero/aspnet-ze ... s.json#L16</a>.
Thanks.