[backend/asp] Add explicit routes for matching local and remote users

This is necessary because MapFallbackToPage doesn't apply to routes containing special characters (dots, @ symbol) by default.
This commit is contained in:
Laura Hausmann 2024-05-29 20:04:22 +02:00
parent 581d13bd65
commit 3d15ed6807
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 9 additions and 2 deletions

View file

@ -46,6 +46,13 @@ public static class WebApplicationExtensions
return app; return app;
} }
public static void MapFrontendRoutes(this WebApplication app, string page)
{
app.MapFallbackToPage(page).WithOrder(int.MaxValue - 2);
app.MapFallbackToPage("/@{user}", page).WithOrder(int.MaxValue - 1);
app.MapFallbackToPage("/@{user}@{host}", page);
}
public static async Task<Config.InstanceSection> Initialize(this WebApplication app, string[] args) public static async Task<Config.InstanceSection> Initialize(this WebApplication app, string[] args)
{ {
var instanceConfig = app.Configuration.GetSection("Instance").Get<Config.InstanceSection>() ?? var instanceConfig = app.Configuration.GetSection("Instance").Get<Config.InstanceSection>() ??

View file

@ -69,7 +69,7 @@ app.MapFallbackToController("/api/{**slug}", "FallbackAction", "Fallback");
app.MapHub<ExampleHub>("/hubs/example"); app.MapHub<ExampleHub>("/hubs/example");
app.MapHub<StreamingHub>("/hubs/streaming"); app.MapHub<StreamingHub>("/hubs/streaming");
app.MapRazorPages(); app.MapRazorPages();
app.MapFallbackToPage("/Shared/FrontendSPA"); app.MapFrontendRoutes("/Shared/FrontendSPA");
app.Urls.Clear(); app.Urls.Clear();
if (config.ListenSocket == null) if (config.ListenSocket == null)