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

后端 未结 7 909
再見小時候
再見小時候 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

    You cannot use both AllowAnyOrigin() and AllowCredentials() at the sametime so change your code to:

    ...
    services.AddCors();
    ...
    app.UseCors(builder => builder
        .WithOrigins("https://example.com")
        .AllowAnyMethod()
        .AllowAnyHeader()
        .AllowCredentials());
    

提交回复
热议问题