Developer Tools / Methrax.Bff.AspNetCore / Samples & Production Patterns
Samples & Production Patterns
The source repository includes a working sample under /Samples with an ASP.NET Core BFF server and Angular client.
Repository sample
Samples/Bff.Server— ASP.NET Core BFF hostSamples/Angular.Client— browser SPA- OIDC integration with providers such as Keycloak
- Server-side session storage through
ITicketStore - YARP reverse proxy integration
TokenForwardingHandlerfor namedHttpClientcalls
Reference topology
flowchart TB
SPA[Angular Client] -->|HttpOnly session cookie| BFF[Bff.Server]
BFF <-->|OIDC| IDP[Identity Provider]
BFF <-->|ticket| STORE[(ITicketStore)]
BFF -->|YARP proxy + access token| API1[Service A]
BFF -->|HttpClient + TokenForwardingHandler| API2[Service B]
Token-forwarding pattern
builder.Services.AddHttpContextAccessor();
builder.Services.AddTransient<TokenForwardingHandler>();
builder.Services
.AddHttpClient("downstream-api", client =>
{
client.BaseAddress = new Uri("https://api.internal.example.com/");
})
.AddHttpMessageHandler<TokenForwardingHandler>();
Use the source repository and package version release notes together when upgrading because framework targets and defaults may change between releases.