diff options
| author | crobibero <cody@robibe.ro> | 2020-09-02 08:03:15 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-09-02 08:03:15 -0600 |
| commit | 1feee6f95e00cf579ab16c7ca004947534545d9b (patch) | |
| tree | b3d0e63ed2f163317894c1353b631979bbafb815 /Jellyfin.Server/Startup.cs | |
| parent | 0b38ac9a8a141149dfe5531c4f96b4d462939aaa (diff) | |
Properly host static files and set base url
Diffstat (limited to 'Jellyfin.Server/Startup.cs')
| -rw-r--r-- | Jellyfin.Server/Startup.cs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs index cbc1c040c..73c00260e 100644 --- a/Jellyfin.Server/Startup.cs +++ b/Jellyfin.Server/Startup.cs @@ -9,9 +9,12 @@ using MediaBrowser.Common; using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Extensions; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; using Prometheus; @@ -44,7 +47,7 @@ namespace Jellyfin.Server { services.AddResponseCompression(); services.AddHttpContextAccessor(); - services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/'), _applicationHost.GetApiPluginAssemblies()); + services.AddJellyfinApi(_applicationHost.GetApiPluginAssemblies()); services.AddJellyfinApiSwagger(); @@ -75,10 +78,12 @@ namespace Jellyfin.Server /// <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) + IServerApplicationHost serverApplicationHost, + IConfiguration appConfig) { if (env.IsDevelopment()) { @@ -95,6 +100,16 @@ namespace Jellyfin.Server // TODO app.UseMiddleware<WebSocketMiddleware>(); + app.UsePathBase(_serverConfigurationManager.Configuration.BaseUrl); + if (appConfig.HostWebClient()) + { + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider(_serverConfigurationManager.ApplicationPaths.WebPath), + RequestPath = "/web" + }); + } + app.UseAuthentication(); app.UseJellyfinApiSwagger(_serverConfigurationManager); app.UseRouting(); @@ -102,7 +117,7 @@ namespace Jellyfin.Server app.UseAuthorization(); if (_serverConfigurationManager.Configuration.EnableMetrics) { - // Must be registered after any middleware that could chagne HTTP response codes or the data will be bad + // Must be registered after any middleware that could change HTTP response codes or the data will be bad app.UseHttpMetrics(); } |
