CORS header not being set for internal server error response ASP.NET Core 3.1

后端 未结 1 846
滥情空心
滥情空心 2021-01-28 05:38

Here is my CORS configuration:

services.AddCors(options =>
{
    options.AddPolicy(name: \"AllowedOrigins\",
        policyBuilder =>
        {
                    


        
相关标签:
1条回答
  • 2021-01-28 06:18

    You need to explicitly call app.UseExceptionHandler(...) in your startup.

    If you do not, then unhandled exceptions bubble up the call stack all the way to Kestrel. And Kestrel does not call the delegates hooked up to HttpContext.Response.OnStarting(...). CorsMiddleware (and many other middleware) use OnStarting to hook into adding information to the response.

    0 讨论(0)
提交回复
热议问题