How to fix “The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time” error

后端 未结 7 894
再見小時候
再見小時候 2021-02-03 17:10

I\'ve already enabled CORS on the project in C# .net Core

In startup.cs I\'ve added lines

...
services.AddCors();
...
app.UseCors(builder =         


        
7条回答
  •  无人及你
    2021-02-03 17:42

    Step 1 Install nuGet package :
    Microsoft.AspNetCore.Cors

    Step 2 add

    services.AddCors();
    

    in startup.cs under ConfigureServices

    Step 3 add

        app.UseCors(x => x
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .SetIsOriginAllowed(origin => true) // allow any origin
                    .AllowCredentials());
    

    in startup.cs under Configure

提交回复
热议问题