WebApi允许跨域
services.AddCors(options => { options.AddPolicy("abc", builder => { //App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma. builder .SetIsOriginAllowed(_ => true) .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); });
app.UseCors("abc"); //这句代码要放在所有 app.xxx() 前面