using Microsoft.Extensions.DependencyInjection; namespace HuanMeng.DotNetCore.CustomExtension { /// /// 添加跨域 /// public static class CorsExtension { /// /// 添加跨域 /// /// /// public static void AddCustomCors(this IServiceCollection services, string policyName) { services.AddCors(options => { options.AddPolicy(policyName, builder => { builder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); } } }