diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-09-10 18:53:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-10 18:53:53 -0500 |
| commit | f71b893e6b625b12906537166b332d550ed5f115 (patch) | |
| tree | bc12e54517168e1124bb78251496982dc64bc07d /src | |
| parent | d5c3922ad1b8093c208fdf6ab5239af0b036c65c (diff) | |
| parent | 99cbe43333a70ddf2bfb384b1d7e018343810446 (diff) | |
| download | slskd-f71b893e6b625b12906537166b332d550ed5f115.tar.gz | |
Merge pull request #1843 from slskd/favicon
Tweak favicon URL handling (again)
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Program.cs | 11 | ||||
| -rw-r--r-- | src/web/src/components/AppFooter.jsx | 3 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index c998d319..b1f57ce4 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -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 diff --git a/src/web/src/components/AppFooter.jsx b/src/web/src/components/AppFooter.jsx index 31550276..b07af7a2 100644 --- a/src/web/src/components/AppFooter.jsx +++ b/src/web/src/components/AppFooter.jsx @@ -1,3 +1,4 @@ +import { urlBase } from '../config'; import { formatBytes } from '../lib/util'; import React from 'react'; import { Icon, Menu } from 'semantic-ui-react'; @@ -69,7 +70,7 @@ const AppFooter = ({ <img alt="" className="footer-logo" - src="./favicon.ico" + src={`${urlBase}/favicon.ico`} /> slskd {current && <span className="footer-version">{current}</span>} |
