Assign webroot for static files

Removes the need for PhysicalFileProvider
This commit is contained in:
flightlevel 2018-08-05 15:31:54 +10:00
parent db39b6afd9
commit 052e382d93
3 changed files with 3 additions and 11 deletions

View File

@ -33,7 +33,6 @@
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="2.1.1" />
<PackageReference Include="NLog" Version="4.5.6" /> <PackageReference Include="NLog" Version="4.5.6" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.5.4" /> <PackageReference Include="NLog.Web.AspNetCore" Version="4.5.4" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.5.0" /> <PackageReference Include="System.ServiceProcess.ServiceController" Version="4.5.0" />

View File

@ -14,7 +14,6 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Jackett.Server namespace Jackett.Server
@ -50,7 +49,7 @@ namespace Jackett.Server
{ {
//TODO: Remove libcurl once off owin //TODO: Remove libcurl once off owin
bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("Core", StringComparison.OrdinalIgnoreCase) >= 0; bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("Core", StringComparison.OrdinalIgnoreCase) >= 0;
if (runningOnDotNetCore) if (runningOnDotNetCore)
{ {
options.Client = "httpclientnetcore"; options.Client = "httpclientnetcore";
@ -182,6 +181,7 @@ namespace Jackett.Server
WebHost.CreateDefaultBuilder(args) WebHost.CreateDefaultBuilder(args)
.UseConfiguration(Configuration) .UseConfiguration(Configuration)
.UseContentRoot(contentRoot) .UseContentRoot(contentRoot)
.UseWebRoot(contentRoot)
.UseUrls(urls) .UseUrls(urls)
.PreferHostingUrls(true) .PreferHostingUrls(true)
.UseStartup<Startup>() .UseStartup<Startup>()

View File

@ -18,7 +18,6 @@ using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Rewrite; using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System; using System;
using System.IO; using System.IO;
@ -128,13 +127,7 @@ namespace Jackett.Server
app.UseRewriter(rewriteOptions); app.UseRewriter(rewriteOptions);
app.UseFileServer(new FileServerOptions app.UseStaticFiles();
{
FileProvider = new PhysicalFileProvider(Helper.ConfigService.GetContentFolder()),
RequestPath = "",
EnableDefaultFiles = true,
EnableDirectoryBrowsing = false
});
app.UseAuthentication(); app.UseAuthentication();