Skip to content

Serve the web UI under any URL prefix - #1532

Open
swelborn wants to merge 6 commits into
bluesky:mainfrom
swelborn:serve-ui-under-url-prefix
Open

swelborn wants to merge 6 commits into
bluesky:mainfrom
swelborn:serve-ui-under-url-prefix

Conversation

@swelborn

@swelborn swelborn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

This is stacked on #1530, so that will merge first. There is some issue with stacked branches as a fork contributor...

The UI build hardcoded /ui/ as its base path, so serving Tiled behind a
reverse-proxy prefix meant rebuilding the frontend.

Now one build serves any prefix:

  • The build uses relative asset URLs and <base href="/ui/" />.
  • The server rewrites the <base> per request from the ASGI root_path.
  • The frontend derives its UI and API URLs from document.baseURI.
  • The build fails if Vite drops the tag. At startup, the server warns if
    the tag is missing and serves the file unmodified, so vendored UIs work.
  • Auth calls use api_url from ui settings.

Breaking: TILED_BUILD_PUBLIC_PATH is ignored. Set uvicorn.root_path (or pass root_path to your ASGI server) instead.

Docs: user-guide/serve-behind-reverse-proxy.md.

🤖 Generated with Claude Code


This is part 2 of 2 in a stack made with GitButler:

swelborn and others added 6 commits September 22, 2026 16:05
uvicorn does not normalize root_path and builds the ASGI scope's path as
root_path + path, so a value written as "tiled" or "/tiled/" corrupts
every URL the server generates. Coerce it to "" or "/prefix" in config
validation, before uvicorn ever sees it, and again when reading it back
out of a request scope.
uvicorn sets scope['path'] to root_path + path, and get_root_url() also
appends root_path, so the code-exchange redirect_uri repeated the prefix
and no longer matched the one sent to /authorize. Build it from
get_current_url, which counts the prefix exactly once.

Replace the OIDC MockRequest with a real Request, so its url is derived
from its scope rather than hardcoded independently of it.
going to landing page without trailing slash resolved it against the parent directory and produced /ui/browse/ instead of /tiled/ui/browse/.
The built UI hardcoded /ui/ as its base path, so a deployment behind a
reverse proxy prefix had to rebuild the frontend. Build it with relative
asset URLs and a <base href="/ui/"> that the server rewrites per
request from the ASGI root_path, the same source get_root_url uses; the
frontend derives the API and UI URLs from that base. One build now
serves any prefix; TILED_BUILD_PUBLIC_PATH can no longer be honored and
warns when set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check that web-frontend/index.html still carries the <base> tag the
server rewrites, so the two cannot drift apart silently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@swelborn
swelborn force-pushed the serve-ui-under-url-prefix branch from 8e458b5 to 2043c3b Compare September 22, 2026 20:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant