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

前端 未结 3 730
栀梦
栀梦 2021-02-15 04:21

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

3条回答
  •  眼角桃花
    2021-02-15 04:56

    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"));
        ...
    }
    

提交回复
热议问题