diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-01 09:57:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-01 09:57:24 -0500 |
| commit | 940bddb03e0841458d587883c4ab51866852ae5d (patch) | |
| tree | 580bc4f54220e6a71e580ca6a679e2adc545fe40 /src/slskd/Program.cs | |
| parent | 93e7bfa63a802563067757696bbed803d2cd5774 (diff) | |
| parent | ff2b8efa65f42afb05e4227965f7920599d8bd97 (diff) | |
| download | slskd-940bddb03e0841458d587883c4ab51866852ae5d.tar.gz | |
Merge branch 'master' into dockerfile
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 5260760f..b1f57ce4 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -512,7 +512,7 @@ namespace slskd Log.Information("Storing application data in {DataDirectory}", DataDirectory); - if (OptionsAtStartup.Logger.Disk) + if (!OptionsAtStartup.Logger.NoDisk) { Log.Information("Saving application logs to {LogDirectory}", LogDirectory); } @@ -1067,12 +1067,17 @@ namespace slskd var urlBase = OptionsAtStartup.Web.UrlBase; urlBase = urlBase.StartsWith("/") ? urlBase : "/" + urlBase; - // use urlBase. this effectively just removes urlBase from the path. - // inject urlBase into any html files we serve, and rewrite links to ./static or /static to - // prepend the url base. + // use urlBase. this effectively just removes urlBase from the path before sending it to the next middleware app.UsePathBase(urlBase); + + // rewrite relative html links to ./static or ./favicon.ico to absolute links that include urlBase + // this is necessary because SPA routers (like React Router) mess with the browser's current address app.UseHTMLRewrite("((\\.)?\\/static)", $"{(urlBase == "/" ? string.Empty : urlBase)}/static"); + app.UseHTMLRewrite("((\\.)?\\/favicon\\.ico)", $"{(urlBase == "/" ? string.Empty : urlBase)}/favicon.ico"); + + // inject urlBase and port into any html files we serve as a window-scoped javascript variable app.UseHTMLInjection($"<script>window.urlBase=\"{urlBase}\";window.port={OptionsAtStartup.Web.Port}</script>", excludedRoutes: new[] { "/api", "/swagger" }); + Log.Information("Using base url {UrlBase}", urlBase); // serve static content from the configured path @@ -1242,7 +1247,7 @@ namespace slskd outputTemplate: (OptionsAtStartup.Debug ? "[{SourceContext}] " : string.Empty) + "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.Async(config => config.Conditional( - e => OptionsAtStartup.Logger.Disk, + e => !OptionsAtStartup.Logger.NoDisk, config => config.File( Path.Combine(LogDirectory, $"{AppName}-.log"), outputTemplate: (OptionsAtStartup.Debug ? "[{SourceContext}] " : string.Empty) + "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}", |
