From a7585dd2d65895620ab82973c9cd72991b5ed38b Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sat, 7 Aug 2021 07:36:45 -0600 Subject: [PATCH 1/2] Fix redirect logic if request path is exactly the base url --- Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs b/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs index 2eef223e52..e3f3911f98 100644 --- a/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs +++ b/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs @@ -58,9 +58,12 @@ namespace Jellyfin.Server.Middleware return; } - if (!startsWithBaseUrl) + if (!startsWithBaseUrl + || localPath.Equals(baseUrlPrefix, StringComparison.OrdinalIgnoreCase) + // Local path is /baseUrl/ + || (localPath.Length == baseUrlPrefix.Length + 1 && localPath[^1] == '/')) { - // Always redirect back to the default path if the base prefix is invalid or missing + // Always redirect back to the default path if the base prefix is invalid, missing, or is the full path. _logger.LogDebug("Normalizing an URL at {LocalPath}", localPath); httpContext.Response.Redirect(baseUrlPrefix + "/" + _configuration[ConfigurationExtensions.DefaultRedirectKey]); return; From bdbac12d4f35bf47e75ed25c7bb10c0074e4f4ce Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sat, 7 Aug 2021 09:06:31 -0600 Subject: [PATCH 2/2] Update Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs Co-authored-by: Claus Vium --- Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs b/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs index e3f3911f98..3e5982eedf 100644 --- a/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs +++ b/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs @@ -59,7 +59,7 @@ namespace Jellyfin.Server.Middleware } if (!startsWithBaseUrl - || localPath.Equals(baseUrlPrefix, StringComparison.OrdinalIgnoreCase) + || localPath.Length == baseUrlPrefix.Length // Local path is /baseUrl/ || (localPath.Length == baseUrlPrefix.Length + 1 && localPath[^1] == '/')) {