Skip to content

WebUI unusable behind a path-prefix reverse proxy (renders its own 404; API calls escape the prefix) #294

Description

@SelfRef

Use case

llama-swap (https://github.com/mostlygeek/llama-swap) can manage audiocpp_server
as an on-demand TTS backend: it starts/stops one instance per configured model and
proxies it under a path prefix, e.g. https://host/upstream/<model>/. The OpenAI
endpoints work great this way - but the embedded WebUI does not.

Problem

The WebUI is a SvelteKit app built for the domain root:

  1. Pathname routing - the document is served fine at
    /upstream/<model>/ (HTTP 200), but the client-side router resolves the
    current location.pathname, finds no matching route, and renders the
    app's own 404 page. So any path-prefix deployment shows "404" even though
    the server is healthy.
  2. Root-absolute API calls - src/lib/api.ts fetches /health,
    /v1/models, /v1/audio/speech, … with absolute paths, so behind a prefix
    they escape to the proxy root instead of reaching the instance.

What fixed it for me (tested)

  • svelte.config.js: kit.router = { type: 'hash' } - the pathname stops
    mattering, and paths.relative: true (already set) keeps assets working.
    Requires dropping the prerender/ssr page options from
    src/routes/+page.ts (hash router rejects them at build time).
  • Rebasing the root-absolute fetches onto the page's directory. I used a
    small window.fetch wrapper in app.html (no-op when served at a real
    root); making the api.ts paths relative would be the cleaner in-tree fix.

With those two changes the full UI (model load, TTS, cloning) works behind
/upstream/<model>/ with zero proxy configuration. Happy to send a PR if
you're open to either approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions