question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

middleware pipeline misconfiguration issue

See original GitHub issue

Although endpoints respond with correct status codes, all endpoints do not omit the content of the response body.

The upgrade was only a few changes I made. other than trivial code changes…

    var builder = WebApplication.CreateBuilder(args);

    await DB.InitAsync(
        builder.Configuration["DatabaseName"],
        MongoClientSettings.FromConnectionString(builder.Configuration["ConnectionString"]));

    builder.Host.UseSerilog((ctx, lc) => lc
        .WriteTo.Console()
        .ReadFrom.Configuration(ctx.Configuration));

    builder.Services.AddScoped<IUserRepository, UserRepository>();
    builder.Services.AddScoped<IPlannerRepository, PlannerRepository>();
    builder.Services.AddScoped<ICourseRepository, CourseRepository>();
    builder.Services.AddScoped<ICourseRetriever, CourseRetriever>();

    builder.Services.AddCors();
    builder.Services.AddFastEndpoints();
    builder.Services.AddSwaggerDoc();
    builder.Services.AddResponseCaching();
    builder.Services.Configure<JsonOptions>(option =>
        option.SerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase);

    FirebaseApp.Create(new AppOptions
    {
        Credential =
            GoogleCredential.FromFile(@"./anteater-pathway-71271-firebase-adminsdk-bgz2p-79df6c1846.json")
    });

    builder.Services
        .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddJwtBearer(option =>
        {
            option.Authority = builder.Configuration["Jwt:Firebase:ValidIssuer"];
            option.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuer = true,
                ValidateAudience = true,
                ValidateLifetime = true,
                ValidateIssuerSigningKey = true,
                ValidIssuer = builder.Configuration["Jwt:Firebase:ValidIssuer"],
                ValidAudience = builder.Configuration["Jwt:Firebase:ValidAudience"]
            };
        });


    var app = builder.Build();

    app.UseSerilogRequestLogging();
    app.UseCors(b => b.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
    app.UseFastEndpoints();
    app.UseRouting();
    app.UseAuthentication();
    app.UseAuthorization();
    app.UseResponseCaching();

    if (app.Environment.IsDevelopment())
    {
        app.UseOpenApi();
        app.UseSwaggerUi3(s => s.ConfigureDefaults());
    }
    else
    {
        app.UseDefaultExceptionHandler();
    }

    app.Run();

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dj-nitehawkcommented, Jan 26, 2022

ok thanks! will push a fix soon…

0reactions
dj-nitehawkcommented, Jan 26, 2022

awesome! will push 3.1.3 final in a few minutes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

middleware pipeline misconfiguration issue #32
Although endpoints respond with correct status codes, all endpoints do not omit the content of the response body. The upgrade was only a...
Read more >
Understanding your middleware pipeline in .NET 6 with the ...
In this post I introduce the Microsoft.AspNetCore.MiddlewareAnalysis package and show how to use it to visualise the middleware in your .
Read more >
Understanding your middleware pipeline with the ...
In this post, I will take a look at the Microsoft.AspNetCore.MiddlewareAnalysis package, which uses an IStartupFilter and DiagnosticSource to ...
Read more >
Why is middleware not executed when there are multiple ...
Actually, it never runs, the breakpoint is never hit. The first call to app.UseEndpoints is where the routing is executed and controller methods ......
Read more >
ASP.NET Core Middleware
Middleware is software that's assembled into an app pipeline to handle requests and responses. Each component: Chooses whether to pass the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found