Kaynağa Gözat

Fix URI creation in redirection middleware (#8551)

Shadowghost 2 yıl önce
ebeveyn
işleme
8653625791

+ 3 - 2
Jellyfin.Server/Middleware/BaseUrlRedirectionMiddleware.cs

@@ -65,8 +65,9 @@ namespace Jellyfin.Server.Middleware
                 // 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 or missing
                 _logger.LogDebug("Normalizing an URL at {LocalPath}", localPath);
                 _logger.LogDebug("Normalizing an URL at {LocalPath}", localPath);
 
 
-                var uri = new Uri(localPath);
-                var redirectUri = new Uri(baseUrlPrefix + "/" + _configuration[DefaultRedirectKey]);
+                var port = httpContext.Request.Host.Port ?? -1;
+                var uri = new UriBuilder(httpContext.Request.Scheme, httpContext.Request.Host.Host, port, localPath).Uri;
+                var redirectUri = new UriBuilder(httpContext.Request.Scheme, httpContext.Request.Host.Host, port, baseUrlPrefix + "/" + _configuration[DefaultRedirectKey]).Uri;
                 var target = uri.MakeRelativeUri(redirectUri).ToString();
                 var target = uri.MakeRelativeUri(redirectUri).ToString();
                 _logger.LogDebug("Redirecting to {Target}", target);
                 _logger.LogDebug("Redirecting to {Target}", target);