Axios和.Net Core 跨域配置(当后台启用windows验证的情况)

时间:2020-11-23 12:38:19   收藏:0   阅读:18

前台Axios配置:

axios.defaults.withCredentials = true;

 

.Net Core 后台配置:

#region CORS
            //跨域方法,先注入服务,声明策略,然后再下边app中配置开启中间件
            services.AddCors(c =>
            {
                //一般采用这种方法
                c.AddPolicy("LimitRequests", policy =>
                {

                    policy.AllowCredentials() 
                    .AllowAnyOrigin()
                    //.WithOrigins("http://localhost:8080")//支持多个域名端口,注意端口号后不要带/斜杆
                    .AllowAnyHeader()//Ensures that the policy allows any header.
                    .AllowAnyMethod();
                });
            });

            #endregion

 

 
 
 
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!