You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
960 B
960 B
跨域(CORS)
- 允许指定策略
"App": {
// 逗号分隔
"CorsOrigins": "http://*.com,http://localhost:4200"
},
- 配置跨域
private void ConfigureCors(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}