Credentials flag is 'true', but the 'Access-Control-Allow-Credentials

前端 未结 4 1231
失恋的感觉
失恋的感觉 2021-02-15 03:59

I am trying to connect to a ASP.NET Web-API Web Service from an AngularJS page and I am getting the following

Credentials flag is \'true\', but the \'Access-Control-Al

4条回答
  •  春和景丽
    2021-02-15 05:02

    I came across this question while trying to hit a webapi on .net core from an angular2 app. I had to add AllowCredentials() to the cors configuration in my Configure method in the Startup.cs to look like the following.

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        ...
        app.UseCors(builder =>
            builder
            .AllowCredentials()
            .WithOrigins("http://localhost:3000"));
        ...
    }
    

提交回复
热议问题