aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-02 18:57:13 -0500
committerJP Dillingham <jp@dillingham.me>2026-10-02 18:57:13 -0500
commit2820f93e8967d2b80e9e1c556113655ac4a5474e (patch)
tree6a377f482ce1b986cb0935d8654dd594bf0851aa /src/slskd/Program.cs
parentffd4a8c60476fe75d3c37d8323b51b4367fb7492 (diff)
parent072a8338e92d154772db678cf5f182d9c6150fc3 (diff)
downloadslskd-2820f93e8967d2b80e9e1c556113655ac4a5474e.tar.gz
Merge remote-tracking branch 'origin/master' into logs
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index def4c2aa..cfe8bcba 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:yyyy-MM-ddTHH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}",