fix(webui): use relative asset base so fonts and lazy chunks honor X-Forwarded-Prefix (#10889) (#10904)

The Vite build emitted path-absolute asset URLs (base: '/'). index.html
entry scripts and the favicon were rewritten to include the reverse-proxy
prefix in serveIndex, but two reference kinds are not in index.html and so
bypassed that rewrite:

  - CSS `url()` font references (e.g. Font Awesome .woff2), which the browser
    resolves relative to the stylesheet and which `<base href>` never affects
  - lazily-imported route chunks, whose preload base came from the absolute
    Vite base

Under a subpath mount (X-Forwarded-Prefix: /llm/) both were fetched from the
origin root, 404ing — missing-glyph "tofu" icons and broken lazy-loaded pages.

Switch Vite to a relative base ('./') so every generated URL resolves against
the file that references it: CSS fonts and route chunks now load from
`/llm/assets/...`, and index.html's now-relative entry refs resolve via the
`<base href>` serveIndex already injects on every response. Root deployments
are unaffected. The existing path-absolute rewrite in app.go still covers the
public `/favicon.svg`.


Assisted-by: Claude:opus-4.8 [Claude Code]

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
localai-org-maint-bot
2026-07-18 08:38:26 +02:00
committed by GitHub
parent 2f011094d9
commit 0389495388

View File

@@ -32,7 +32,15 @@ export default defineConfig({
]
: []),
],
base: '/',
// Relative base so every generated URL (entry scripts in index.html, CSS
// `url()` font references, and lazily-imported route chunks) resolves against
// the file that references it rather than the origin root. When LocalAI is
// served under a reverse-proxy subpath (X-Forwarded-Prefix, e.g. `/llm/`),
// an absolute `/assets/...` bypasses the prefix and 404s — breaking fonts
// ("tofu" glyphs) and lazy-loaded chunks. index.html's now-relative refs
// resolve via the `<base href>` that serveIndex always injects (see
// core/http/app.go), so both proxied and root deployments load correctly.
base: './',
server: {
port: 3000,
proxy: {