如果当前请求站点域名是wwww.aaa.com,而目标接口的域名地址是www.bbb.com,那么在core框架默认情况下未开启跨域,请求时就会提示错误
1、跨域错误提示
2、后台解决方法
在Startup.cs文件,在如下方法添加代码
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddCors();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCors(builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
}