mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 13:10:13 -07:00
New: Support for running from a sub folder (reverse proxy)
This commit is contained in:
parent
cec479923f
commit
b5c9a811dd
22 changed files with 161 additions and 89 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Nancy;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
|
@ -12,6 +13,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly string _indexPath;
|
||||
private static readonly Regex ReplaceRegex = new Regex("(?<=(?:href|src|data-main)=\").*?(?=\")", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public IndexHtmlMapper(IAppFolderInfo appFolderInfo,
|
||||
IDiskProvider diskProvider,
|
||||
|
@ -47,13 +49,15 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||
return StringToStream(GetIndexText());
|
||||
}
|
||||
|
||||
|
||||
private string GetIndexText()
|
||||
{
|
||||
var text = _diskProvider.ReadAllText(_indexPath);
|
||||
|
||||
text = ReplaceRegex.Replace(text, match => _configFileProvider.UrlBase + match.Value);
|
||||
|
||||
text = text.Replace(".css", ".css?v=" + BuildInfo.Version);
|
||||
text = text.Replace(".js", ".js?v=" + BuildInfo.Version);
|
||||
text = text.Replace("API_ROOT", _configFileProvider.UrlBase + "/api");
|
||||
text = text.Replace("API_KEY", _configFileProvider.ApiKey);
|
||||
text = text.Replace("APP_VERSION", BuildInfo.Version.ToString());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue