Enable OPTIONS header for CORS on .NET Core Web API

后端 未结 7 1601
温柔的废话
温柔的废话 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:39

    This worked for me:

    Make sure that this:

    app.UseCors(builder => {
        builder.AllowAnyOrigin();
        builder.AllowAnyMethod();
        builder.AllowAnyHeader();
    });
    

    Occurs before any of these:

    app.UseHttpsRedirection();
    app.UseDefaultFiles();
    app.UseStaticFiles();
    app.UseCookiePolicy();
    

    Remember, we are dealing with a "pipeline". The cors stuff has to be first.

    -gimzani

提交回复
热议问题