How to enable CORS in ASP.NET Core

前端 未结 12 832
无人及你
无人及你 2020-11-22 14:11

I am trying to enable cross origin resources sharing on my ASP.NET Core Web API, but I am stuck.

The EnableCors attribute accepts policyName

12条回答
  •  鱼传尺愫
    2020-11-22 14:21

    Specifically in dotnet core 2.2 with SignalR you must change

    .WithOrigins("http://localhost:3000") or

    .SetIsOriginAllowed(isOriginAllowed: _ => true) //for all origins

    instead .AllowAnyOrigin() with .AllowCredentials()

    https://trailheadtechnology.com/breaking-change-in-aspnetcore-2-2-for-signalr-and-cors/

    https://github.com/aspnet/AspNetCore/issues/4483

提交回复
热议问题