Redirect to base path from root path (#466)

This commit is contained in:
Flaminel
2026-02-23 17:24:48 +02:00
committed by GitHub
parent 8a2aca79f7
commit df986a2e36

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;
}