services.AddCors(options => options.AddPolicy("AllowCors", builder => builder.AllowAnyOrigin() .WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS"))); app.UseMiddleware<ExceptionMiddleware>(); app.UseCors("AllowCors"); app.UseHttpsRedirection(); app.UseStaticFiles();
app.UseCors("AllowCors")这个方法最好放在
app.UseHttpsRedirection()前面
原文:https://www.cnblogs.com/huanyun/p/14066527.html