.netcore3.1 设置可跨域

原文: .netcore3.1 设置可跨域

1、所有终端都可以调用,代码如下:

复制代码
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    // Preceding code ommitted.
    app.UseRouting();

    app.UseCors();

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
    });

    // Following code ommited.
}
复制代码

通过终结点路由,CORS 中间件必须配置为在对 UseRouting 和 UseEndpoints的调用之间执行。 配置不正确将导致中间件停止正常运行。

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/12242573.html
今日推荐