我收到以下错误
从源“http://localhost: 23456”访问“ http://localhost:5000/api/values/track/?name=name&time=1589425390870 ”处的 XMLHttpRequest 已被 CORS 策略阻止:“Access”的值当请求的凭据模式为“include”时,响应中的“-Control-Allow-Origin”标头不得为通配符“*”。XMLHttpRequest 发起的请求的凭据模式由 withCredentials 属性控制。
我已经配置了 Asp.net core 应用程序,如下所示
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader().AllowCredentials() ;
}));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors("MyPolicy");
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
内容类型:application/x-www-form-urlencoded
有人可以帮我解决这个问题吗?