Repository navigation
Serve the board from a path behind a proxy - #102
Merged
Merged
Conversation
The page, its service worker and the manifest asked for every file and API path from the root, so behind a proxy that serves the board under a path, like /kanzo/, they went to the proxy's root instead. They now ask relative to where they were loaded. A board at the root asks for the same paths as before. Fixes #99
ResourcesIf merged, nothing moves by more than noise. Agents
Program
Memory
Speed
Storage
Measured on GitHub's ubuntu-26.04 runner, median of 3 rounds with the builds taking turns. Changes in bold are past noise: 1% for sizes, 5% for memory, 15% for times. Agents' text is in bytes: add an |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #99
Behind a proxy that serves the board under a path, like
location /kanzo/ { proxy_pass http://kanzo:4242/; }, the page asked for/app.js,/api/...,/sw.jsand the rest at the proxy's root. Now the page, its service worker and the manifest ask for everything relative to where they were loaded, as @baron-hines proposed in #99. There's no new setting, and the server's routes don't change.index.html: the icon, manifest, logo and script.app.js:base()is.or./remote, so API calls and images go to./api/...and./remote/api/.... Also the service worker's registration, the?appaddress,changelog.md, andi18n/zh-cn.js, which Serve the board from a sub-path behind a reverse proxy, with relative URLs #99 didn't list: under a path, the Chinese board stayed in English.sw.js: its fetches, icon and new window are relative, so they resolve against the worker's own address.start_urlis./and the icon isicon.png. It no longer setsid. Anidresolves against the origin, so"./"would give every board on one host the same identity. Without it, the id is thestart_url, which at the root is/as before, so an installed app stays the same app.A board at the root asks for the same paths as before, and
getRegistration("./")there still finds the service worker registered at/.Size
No dependency, setting or MCP change, so nothing an agent gets changes. The page's files change by a few bytes.
Tests
src/web.rs:the_page_asks_for_nothing_from_the_rootchecksindex.html,app.js,sw.jsand the manifest. It fails on main (atsw.js's"/api/push/pending") and passes here.Tried in Chrome, behind Apache at
/kanzo/(ProxyPass "/kanzo/" "http://127.0.0.1:4343/",ProxyPreserveHost On,hosts = ["kanzo.localhost"]), and directly at the root:/kanzo/and/;./remote/api/...and reaching Kanzo.Not tried: a push notification end to end, the installed app, and a real joined board.
cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass