瀏覽代碼

Merge pull request #6162 from crobibero/no-base-redirect

Redirect to default if root is requested
Claus Vium 4 年之前
父節點
當前提交
19a1889906
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs

+ 8 - 0
Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs

@@ -66,6 +66,14 @@ namespace Jellyfin.Server.Middleware
                     return;
                 }
             }
+            else if (string.IsNullOrEmpty(localPath)
+                     || localPath.Equals("/", StringComparison.Ordinal))
+            {
+                // Always redirect back to the default path if root is requested.
+                _logger.LogDebug("Normalizing an URL at {LocalPath}", localPath);
+                httpContext.Response.Redirect("/" + _configuration[ConfigurationExtensions.DefaultRedirectKey]);
+                return;
+            }
 
             await _next(httpContext).ConfigureAwait(false);
         }