Skip to content

Serve the board from a sub-path behind a reverse proxy, with relative URLs #99

Done

Description

@baron-hines

Thanks for hosts (#71). It made Kanzo easy to put behind a proxy at the root. I'd like to run it under a path instead, like http://myserver/kanzo/, next to other apps on one gateway that routes by path. A setup like that has one hostname and one certificate, and each app gets a path.

Today that doesn't work, because the board asks for everything at the root: /app.js, /api/..., /logo.png, /sw.js. Behind location /kanzo/ { proxy_pass http://kanzo:4242/; } those requests go to the proxy's root instead of to Kanzo. Rewriting the responses in the proxy works, but it breaks whenever a path changes in a release.

Proposal: make the board's URLs relative, with no new setting. Kanzo already routes by hash (#all, #<project>) and already prefixes API calls through base(), so it's most of the way there (line numbers from 27d698c):

  • index.html: href="logo.png", icon.png, manifest.webmanifest, src="app.js" (5 places).
  • The manifest in web.rs: "id": "./", "start_url": "./", "src": "icon.png". Relative URLs in a manifest resolve against the manifest's own URL.
  • app.js:
    • base() (line 44) returns "." or "./remote" instead of "" or "/remote", so base() + "/api" + path becomes ./api/...;
    • fetch("changelog.md") (line 2353);
    • register("sw.js") and getRegistration("./") (lines 2041, 2060);
    • history.replaceState(null, "", app ? "./?app" : "./") (line 2023).
  • sw.js: build its URLs from self.registration.scope (new URL("api/push", self.registration.scope), and the same for icon.png and openWindow). It then follows wherever the board was registered.

What doesn't change:

  • the server's routes, the API, MCP over stdio and /mcp;
  • a board at the root behaves exactly as now;
  • there's no new option or dependency.

What I'd test: cargo fmt --check, cargo clippy --all-targets -D warnings and cargo test; the ES2020 parse your syntax test does; and a browser pass in current Chrome, Edge and Firefox, in light and dark, both at the root and behind nginx at /kanzo/:

  • loading, editing, moving and searching cards;
  • attaching and opening images;
  • notifications (the service worker's register, push and click-to-open);
  • installed-app mode (?app);
  • a shared and a joined board.

There's no Safari 13.1, Chrome 80 or Firefox 78 here. The change adds no new syntax (only paths, and new URL(path, scope) in the service worker, which those versions have), so the ES2020 parse stands in for them, as in #90.

Possible follow-up, separate: an icon = "..." key in config.toml that serves a file in place of the built-in logo.png and icon.png, for people who want the board's icon to match their other apps. Happy to leave that out if it's more than you want.

If this approach sounds right, I'll send a PR.

· Generated with Claude Code · Opus 5.5 ·

Activity

  1. emanuele-em commented on Dec 3, 2026

    @emanuele-em
    Owner

    Thanks for the clear proposal! I went ahead with it in #102: every URL the board asks for is now relative, plus i18n/zh-cn.js, which the Chinese board also needs under a path. If you get a chance to try it behind your gateway, that would be great.

  2. baron-hines commented on Dec 3, 2026

    @baron-hines
    Author

    Thanks! I built main at 504993b and ran it behind nginx at /kanzo/ (proxy_pass http://127.0.0.1:4499/, hosts = ["localhost"]), plus at the root for comparison. It works as expected.

    I tested it in current Chromium and Firefox, in light and dark mode, through Playwright. In all 8 runs:

    • a card was made, edited, moved and found by search;
    • an image was attached and shown;
    • changelog.md and i18n/zh-cn.js loaded;
    • the service worker registered with the scope /kanzo/;
    • the manifest's start_url and icon resolved under it;
    • no request left /kanzo/.

    The only refusal was /api/network answering 403, the existing rule for listed hosts.

    We'll put it behind our own gateway once it's in a release.

    · Generated with Claude Code · Opus 5.5 ·

  3. added a commit that references this issue on Dec 3, 2026
    504993b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions