From 68e5a95fdb2d0c99e2490dc117651edb413733c5 Mon Sep 17 00:00:00 2001 From: crobibero Date: Mon, 7 Sep 2020 19:10:14 -0600 Subject: [PATCH] Fix redirection --- Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs | 6 +++++- Jellyfin.Server/Startup.cs | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs b/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs index ae3a3a1c54..9316737bdf 100644 --- a/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs +++ b/Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs @@ -44,7 +44,11 @@ namespace Jellyfin.Server.Middleware var localPath = httpContext.Request.Path.ToString(); var baseUrlPrefix = serverConfigurationManager.Configuration.BaseUrl; - if (!localPath.StartsWith(baseUrlPrefix, StringComparison.OrdinalIgnoreCase)) + if (string.Equals(localPath, baseUrlPrefix + "/", StringComparison.OrdinalIgnoreCase) + || string.Equals(localPath, baseUrlPrefix, StringComparison.OrdinalIgnoreCase) + || string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase) + || string.IsNullOrEmpty(localPath) + || !localPath.StartsWith(baseUrlPrefix, StringComparison.OrdinalIgnoreCase)) { // Always redirect back to the default path if the base prefix is invalid or missing _logger.LogDebug("Normalizing an URL at {LocalPath}", localPath); diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs index 16629b5d95..9e969c0c16 100644 --- a/Jellyfin.Server/Startup.cs +++ b/Jellyfin.Server/Startup.cs @@ -93,11 +93,7 @@ namespace Jellyfin.Server IWebHostEnvironment env, IConfiguration appConfig) { - // Only add base url redirection if a base url is set. - if (!string.IsNullOrEmpty(_serverConfigurationManager.Configuration.BaseUrl)) - { - app.UseBaseUrlRedirection(); - } + app.UseBaseUrlRedirection(); // Wrap rest of configuration so everything only listens on BaseUrl. app.Map(_serverConfigurationManager.Configuration.BaseUrl, mainApp =>