Browse Source

Add cors for the angular UI

pull/21/head
Halil İbrahim Kalkan 5 years ago
parent
commit
921ec10f1b
  1. 20
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs

20
gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs

@ -25,6 +25,25 @@ namespace EShopOnAbp.WebGateway
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerConfigurationHelper.Configure(context, "Web Gateway");
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -38,6 +57,7 @@ namespace EShopOnAbp.WebGateway
}
app.UseCorrelationId();
app.UseCors();
app.UseSwagger();
app.UseSwaggerUI(options =>
{

Loading…
Cancel
Save