From 2d09b579399562bb229350a548c5c4ac3fbbcf2a Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 29 Oct 2022 18:30:20 +0800 Subject: [PATCH] 1 --- BBWY.Server.API/Startup.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/BBWY.Server.API/Startup.cs b/BBWY.Server.API/Startup.cs index fb48bf49..52bb287f 100644 --- a/BBWY.Server.API/Startup.cs +++ b/BBWY.Server.API/Startup.cs @@ -64,10 +64,10 @@ namespace BBWY.Server.API services.AddHttpClient(); services.AddCors(options => { - options.AddDefaultPolicy(p => - { - p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); - }); + options.AddPolicy("cors", p => + { + p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); + }); }); services.AddControllers(configure => { @@ -134,7 +134,7 @@ namespace BBWY.Server.API } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env,YunDingBusiness yunDingBusiness) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, YunDingBusiness yunDingBusiness) { yunDingBusiness.RefreshKey(); app.UseSwagger(c => c.SerializeAsV2 = true) @@ -152,6 +152,8 @@ namespace BBWY.Server.API app.UseRouting(); + app.UseCors("cors"); + app.UseAuthorization(); app.UseEndpoints(endpoints =>