YARP Reverse Proxy not working correctly with Blazor SSR Project in .net8
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 933
- Avg merge
- 12d 18h
- Merged PRs (30d)
- 2
Description
### Describe the bug
We have 2 projects in our solution:
1) Legacy webforms (on .net framework 4.8) and
2) Blazor Server (SSR) project for .net 8.
We have setup YARP for the Blazor project but it doesn't properly work. For resources (bootstrap.min.css, app.css) located in the www folder (of the Blazor app) the YARP proxy forwards them to the legacy webforms app although they exist in the Blazor app.
### To Reproduce
Here's the program file:
```c#
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// web adapters/setup YARP
builder.Services.AddSystemWebAdapters();
builder.Services.AddHttpForwarder();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.UseSystemWebAdapters();
// endpoints
app.MapRazorComponents()
.AddInteractiveServerRenderMode();
// yarp
app.MapForwarder("/{**catch-all}", app.Configuration["ProxyTo"]).Add(static builder => ((RouteEndpointBuilder)builder).Order = int.MaxValue);
app.Run();
```
appsettings.json (omitted logging info)
` "AllowedHosts": "*",
"ProxyTo": "http://localhost:60675/"`
### Further technical details
The webforms runs on .net framework 4.8
The Blazor server app (SSR) runs on .net 8
Testing is done on Windows 10
Contributor guide
Assessment
This issue has not been assessed yet.