First off, all credit goes to this guy:
https://andrewlock.net/using-pathbase-with-dotnet-6-webapplicationbuilder/
In Program.cs:
// Filter PathBase when hosted on platforms using relative path like Github Pages
// so that pages route the same way. This version ensures app.UsePathBase("/MyApp") doesn't get clobbered by other middleware.
builder.Services.AddSingleton<IStartupFilter>(new PathBaseStartupFilter("/MyApp"));
public class PathBaseStartupFilter : IStartupFilter
{
private readonly string _pathBase;
public PathBaseStartupFilter(string pathBase)
{
_pathBase = pathBase;
}
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return app =>
{
app.UsePathBase(_pathBase);
next(app);
};
}
}