Run the web UI under a path behind a reverse proxy (e.g. /jellymove/) #7

Open
opened 2026-11-09 11:40:18 +01:00 by Claude · 0 comments

Problem

The web UI only works at the root of a site. Behind a reverse proxy at a path such as https://example.com/jellymove/, the page loads but stays blank:

  • index.html loads its script from /assets/index-….js, which is the site root, not /jellymove/assets/. That request never reaches the proxy's /jellymove/ location.
  • The UI calls the API at /api/... and opens the live event stream at /api/events, both from the root (ui/src/lib/api.ts, ui/src/lib/moves.svelte.ts).

A subdomain avoids this but isn't always possible, for example on a shared VPS where the only option is a path on an existing site.

Proposal

Make every URL the UI uses relative, so the same build works at / and under any path:

  • Set base: './' in ui/vite.config.ts so built asset URLs are relative.
  • Call the API as api/... and open the stream as api/events (no leading /). The SPA has no client-side routes, so relative URLs always resolve against the page's own path.
  • The proxy strips the prefix (proxy_pass http://127.0.0.1:PORT/; with a trailing slash), so the server needs no changes and the peer API is unaffected.
  • /jellymove without the trailing slash would resolve relative URLs wrongly. Document the proxy redirect for it (location = /jellymove { return 301 /jellymove/; }), or detect it in the UI.

Alternative if prefix stripping turns out to be awkward: a ui.base_path setting that makes the server mount the UI and /api under that prefix. Only do this if relative URLs aren't enough.

Done when

  • The UI works at / (as today) and behind nginx at /jellymove/: library, moves with live updates, trash and status.
  • The Vite dev server (npm --prefix ui run dev) still works.
  • The README has a working nginx example for a path, including proxy_buffering off; so live move updates aren't held back, and proxy_http_version 1.1.
  • The README says the peer must reach the agent directly, not through a proxy location that has its own login, as the peer uses the Authorization header for its token.
  • A test checks that the built index.html has no root-relative (/assets/…) URLs.

Notes

#8 (login page) sets a session cookie. Its Path must follow whatever path the UI is served under, so whichever lands second should check the two together.

## Problem The web UI only works at the root of a site. Behind a reverse proxy at a path such as `https://example.com/jellymove/`, the page loads but stays blank: - `index.html` loads its script from `/assets/index-….js`, which is the site root, not `/jellymove/assets/`. That request never reaches the proxy's `/jellymove/` location. - The UI calls the API at `/api/...` and opens the live event stream at `/api/events`, both from the root (`ui/src/lib/api.ts`, `ui/src/lib/moves.svelte.ts`). A subdomain avoids this but isn't always possible, for example on a shared VPS where the only option is a path on an existing site. ## Proposal Make every URL the UI uses relative, so the same build works at `/` and under any path: - Set `base: './'` in `ui/vite.config.ts` so built asset URLs are relative. - Call the API as `api/...` and open the stream as `api/events` (no leading `/`). The SPA has no client-side routes, so relative URLs always resolve against the page's own path. - The proxy strips the prefix (`proxy_pass http://127.0.0.1:PORT/;` with a trailing slash), so the server needs no changes and the peer API is unaffected. - `/jellymove` without the trailing slash would resolve relative URLs wrongly. Document the proxy redirect for it (`location = /jellymove { return 301 /jellymove/; }`), or detect it in the UI. Alternative if prefix stripping turns out to be awkward: a `ui.base_path` setting that makes the server mount the UI and `/api` under that prefix. Only do this if relative URLs aren't enough. ## Done when - The UI works at `/` (as today) and behind nginx at `/jellymove/`: library, moves with live updates, trash and status. - The Vite dev server (`npm --prefix ui run dev`) still works. - The README has a working nginx example for a path, including `proxy_buffering off;` so live move updates aren't held back, and `proxy_http_version 1.1`. - The README says the peer must reach the agent directly, not through a proxy location that has its own login, as the peer uses the `Authorization` header for its token. - A test checks that the built `index.html` has no root-relative (`/assets/…`) URLs. ## Notes #8 (login page) sets a session cookie. Its `Path` must follow whatever path the UI is served under, so whichever lands second should check the two together.
Claude Bot added this to the v0.3.0 milestone 2026-11-09 11:40:18 +01:00
Claude Bot added the
Priority
High
2
Kind/Enhancement
labels 2026-11-09 11:40:18 +01:00
Sign in to join this conversation.