Enable OPTIONS header for CORS on .NET Core Web API

后端 未结 7 1602
温柔的废话
温柔的废话 2020-11-28 06:55

I solved this problem after not finding the solution on Stackoverflow, so I am sharing my problem here and the solution in an answer.

After enabling a cross domain p

7条回答
  •  囚心锁ツ
    2020-11-28 07:45

    I know it has been answered. Just answering with the updated information. So it would help others.

    It is now built into the ASP.NET Core framework.

    Just follow https://docs.microsoft.com/en-us/aspnet/core/security/cors

    and replace

        app.UseCors(builder =>
       builder.WithOrigins("http://example.com"));
    

    with

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

提交回复
热议问题