| 
					
				 | 
			
			
				@@ -88,71 +88,78 @@ namespace Jellyfin.Server 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /// <param name="app">The application builder.</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /// <param name="env">The webhost environment.</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// <param name="serverApplicationHost">The server application host.</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /// <param name="appConfig">The application config.</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public void Configure( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             IApplicationBuilder app, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             IWebHostEnvironment env, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            IServerApplicationHost serverApplicationHost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             IConfiguration appConfig) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (env.IsDevelopment()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Only add base url redirection if a base url is set. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!string.IsNullOrEmpty(_serverConfigurationManager.Configuration.BaseUrl)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                app.UseDeveloperExceptionPage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                app.UseBaseUrlRedirection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseMiddleware<ExceptionMiddleware>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Wrap rest of configuration so everything only listens on BaseUrl. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            app.Map(_serverConfigurationManager.Configuration.BaseUrl, mainApp => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (env.IsDevelopment()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    mainApp.UseDeveloperExceptionPage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseMiddleware<ResponseTimeMiddleware>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseMiddleware<ExceptionMiddleware>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseWebSockets(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseMiddleware<ResponseTimeMiddleware>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseResponseCompression(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseWebSockets(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseCors(ServerCorsPolicy.DefaultPolicyName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseResponseCompression(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (_serverConfigurationManager.Configuration.RequireHttps 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                && _serverApplicationHost.ListenWithHttps) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                app.UseHttpsRedirection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseCors(ServerCorsPolicy.DefaultPolicyName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseStaticFiles(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UsePathBase(_serverConfigurationManager.Configuration.BaseUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (appConfig.HostWebClient()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                app.UseStaticFiles(new StaticFileOptions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (_serverConfigurationManager.Configuration.RequireHttps 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    && _serverApplicationHost.ListenWithHttps) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    FileProvider = new PhysicalFileProvider(_serverConfigurationManager.ApplicationPaths.WebPath), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    RequestPath = "/web" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseAuthentication(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseJellyfinApiSwagger(_serverConfigurationManager); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseRouting(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseAuthorization(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (_serverConfigurationManager.Configuration.EnableMetrics) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // Must be registered after any middleware that could change HTTP response codes or the data will be bad 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                app.UseHttpMetrics(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    mainApp.UseHttpsRedirection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseLanFiltering(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseIpBasedAccessValidation(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseBaseUrlRedirection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseWebSocketHandler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseServerStartupMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UsePathBase(_serverConfigurationManager.Configuration.BaseUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseStaticFiles(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (appConfig.HostWebClient()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    mainApp.UseStaticFiles(new StaticFileOptions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        FileProvider = new PhysicalFileProvider(_serverConfigurationManager.ApplicationPaths.WebPath), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        RequestPath = "/web" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            app.UseEndpoints(endpoints => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                endpoints.MapControllers(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseAuthentication(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseJellyfinApiSwagger(_serverConfigurationManager); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseRouting(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseAuthorization(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (_serverConfigurationManager.Configuration.EnableMetrics) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    endpoints.MapMetrics(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/') + "/metrics"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // Must be registered after any middleware that could change HTTP response codes or the data will be bad 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    mainApp.UseHttpMetrics(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                endpoints.MapHealthChecks(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/') + "/health"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseLanFiltering(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseIpBasedAccessValidation(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseWebSocketHandler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseServerStartupMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                mainApp.UseEndpoints(endpoints => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    endpoints.MapControllers(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (_serverConfigurationManager.Configuration.EnableMetrics) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        endpoints.MapMetrics("/metrics"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    endpoints.MapHealthChecks("/health"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // Add type descriptor for legacy datetime parsing. 
			 |