在将API从2.2 .NET Core迁移到3.0时,我在运行API时遇到以下代码错误。
公共静态void配置(IApplicationBuilder应用)
{
app.UseCors(builder => builder
.WithOrigins(ConfigurationSettings.CORSAllowedSites)
.AllowAnyMethod()
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowCredentials()
);
}
**错误:CORS协议不允许同时指定通配符来源和凭据。 如果需要支持凭据,则通过列出各个来源来配置Cors策略**
答案 0 :(得分:0)
从.AllowCredentials()
方法中删除app.UseCors
,如下所示:
app.UseCors(builder => builder
.WithOrigins(ConfigurationSettings.CORSAllowedSites)
.AllowAnyMethod()
.AllowAnyOrigin()
.AllowAnyHeader()
);