aghk

appsettings.json

"CorsUrls": [
  "http://localhost:9527",
  "https://localhost:3000",
]

 

注册信息        

var cors = Configuration.GetSection("CorsUrls").GetChildren().Select(p => p.Value);
services.AddCors(c =>
{
c.AddPolicy(AllowSpecificOrigins, policy =>
{
policy
.WithOrigins(cors.ToArray())
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
services.AddControllers();

添加管道

         app.UseCors(AllowSpecificOrigins);

分类:

技术点:

相关文章:

  • 2021-12-19
  • 2021-07-30
  • 2021-05-21
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2020-04-07
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案