NET Core3.1 Cors 添加跨域支持

在 Startup 里加:

            services.AddCors(options => options.AddPolicy(
                                 DefaultCors,
                                 p => p.SetIsOriginAllowedToAllowWildcardSubdomains()
                                 .WithOrigins("https://*.cnblogs.com", "http://*.cnblogs.com","https://localhost:44316")
                                 .AllowAnyMethod().AllowAnyHeader()));
        }

再在

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

app.UseCors(DefaultCors);

。。。

}

原文地址:https://www.cnblogs.com/wgscd/p/13083749.html