Redirect to base path from root path (#466)

This commit is contained in:
Flaminel authored and GitHub committed 2026-02-23 17:24:48 +02:00
1 parent 8a2aca79f7
commit df986a2e36
1 file changed
+7
+7
View File
@@ -131,6 +131,13 @@ if (basePath is not null)
{
if (!string.IsNullOrEmpty(basePath) && !context.Request.Path.StartsWithSegments(basePath, StringComparison.OrdinalIgnoreCase))
{
// Redirect root to the base path for convenience
if (!context.Request.Path.HasValue || context.Request.Path.Value == "/")
{
context.Response.Redirect(basePath + "/");
return;
}
context.Response.StatusCode = StatusCodes.Status404NotFound;
return;
}