Merge pull request #4094 from crobibero/fix-redirect

Fix redirection
This commit is contained in:
Bond-009 2020-09-08 11:04:15 +00:00 committed by GitHub
commit 46c8a6c1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -44,7 +44,11 @@ namespace Jellyfin.Server.Middleware
var localPath = httpContext.Request.Path.ToString(); var localPath = httpContext.Request.Path.ToString();
var baseUrlPrefix = serverConfigurationManager.Configuration.BaseUrl; 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 // 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);

View File

@ -93,11 +93,7 @@ namespace Jellyfin.Server
IWebHostEnvironment env, IWebHostEnvironment env,
IConfiguration appConfig) IConfiguration appConfig)
{ {
// Only add base url redirection if a base url is set. app.UseBaseUrlRedirection();
if (!string.IsNullOrEmpty(_serverConfigurationManager.Configuration.BaseUrl))
{
app.UseBaseUrlRedirection();
}
// Wrap rest of configuration so everything only listens on BaseUrl. // Wrap rest of configuration so everything only listens on BaseUrl.
app.Map(_serverConfigurationManager.Configuration.BaseUrl, mainApp => app.Map(_serverConfigurationManager.Configuration.BaseUrl, mainApp =>