Fix URI creation in redirection middleware (#8551)

pull/8697/head
Shadowghost 2 years ago committed by GitHub
parent c306428f2c
commit 8653625791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -65,8 +65,9 @@ namespace Jellyfin.Server.Middleware
// Always redirect back to the default path if the base prefix is invalid or missing
_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();
_logger.LogDebug("Redirecting to {Target}", target);

Loading…
Cancel
Save