- 在
Setup.cs
文件ConfigureServices
函数内添加:
services.AddCors();
- 在
Setup.cs
文件Configure
函数内添加:
app.UseCors(options => options
.AllowAnyHeader() // 确保策略允许任何标头
.AllowAnyMethod() // 确保策略允许任何方法
.SetIsOriginAllowed(o => true) // 设置指定的isOriginAllowed为基础策略
.AllowCredentials()); // 将策略设置为允许凭据。