修改跨域
This commit is contained in:
parent
338697a97f
commit
f3a9acb0ca
|
|
@ -14,14 +14,23 @@ public static class CrossOriginConfig
|
||||||
// 跨域配置 配置跨域处理
|
// 跨域配置 配置跨域处理
|
||||||
webApplicationBuilder.Services.AddCors(options =>
|
webApplicationBuilder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddDefaultPolicy(builder =>
|
options.AddPolicy("_myAllowSpecificOrigins",
|
||||||
{
|
builder =>
|
||||||
builder
|
{
|
||||||
.SetIsOriginAllowed(_ => true)
|
builder
|
||||||
.AllowAnyMethod()
|
.AllowAnyOrigin()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowCredentials();
|
.AllowAnyMethod();
|
||||||
});
|
});
|
||||||
|
//options.AddDefaultPolicy(builder =>
|
||||||
|
//{
|
||||||
|
// builder
|
||||||
|
// .SetIsOriginAllowed(_ => true)
|
||||||
|
// .AllowAnyMethod()
|
||||||
|
// .AllowAnyHeader()
|
||||||
|
// .AllowCredentials();
|
||||||
|
|
||||||
|
//});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,7 +40,7 @@ public static class CrossOriginConfig
|
||||||
public static void UseCrossOrigin(this WebApplication webApplication)
|
public static void UseCrossOrigin(this WebApplication webApplication)
|
||||||
{
|
{
|
||||||
// 使用跨域 警告: 通过终结点路由,CORS 中间件必须配置为在对UseRouting和UseEndpoints的调用之间执行。 配置不正确将导致中间件停止正常运行。
|
// 使用跨域 警告: 通过终结点路由,CORS 中间件必须配置为在对UseRouting和UseEndpoints的调用之间执行。 配置不正确将导致中间件停止正常运行。
|
||||||
webApplication.UseCors();
|
webApplication.UseCors("_myAllowSpecificOrigins");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user