Read the default gateway from the deployment, not the build #2

Merged
natsukium merged 1 commit from feat/same-origin-gateway into main 2026-10-14 13:23:48 +09:00
Owner

The app looked for its gateway only on the page's own host at port 8771, which does not fit a single-origin reverse proxy (app at /, gateway at /gateway). Fixing it at build time would mean rebuilding the app to point it elsewhere, so the default now comes from the deployment.

  • The app fetches /config.json at startup ({"gateway": "/gateway"}) and renders once it has an answer. Missing, unreadable, slow (3 s) or unparseable values fall back to <host>:8771; ?ws= still wins. A path resolves against the page and takes the page's ws/wss scheme.
  • nixosModules.default / darwinModules.default: services.felis-web.settings becomes config.json, and services.felis-web.root is the app plus that file, for a web server's document root.
  • README gains a Deploy section (gateway from felis-web-gateway's module, app from this one, a caddy example).

Verification

  • nix build of services.felis-web.root (includes tsc).
  • Headless Chromium against static servers: config present → ws://<host>/gateway; absent → ws://<host>:8771; ?ws=ws://elsewhere:1 → that; a malformed "http://[" → ws://<host>:8771 with the connect screen shown.
The app looked for its gateway only on the page's own host at port 8771, which does not fit a single-origin reverse proxy (app at `/`, gateway at `/gateway`). Fixing it at build time would mean rebuilding the app to point it elsewhere, so the default now comes from the deployment. - The app fetches `/config.json` at startup (`{"gateway": "/gateway"}`) and renders once it has an answer. Missing, unreadable, slow (3 s) or unparseable values fall back to `<host>:8771`; `?ws=` still wins. A path resolves against the page and takes the page's ws/wss scheme. - `nixosModules.default` / `darwinModules.default`: `services.felis-web.settings` becomes `config.json`, and `services.felis-web.root` is the app plus that file, for a web server's document root. - README gains a Deploy section (gateway from felis-web-gateway's module, app from this one, a caddy example). ## Verification - `nix build` of `services.felis-web.root` (includes `tsc`). - Headless Chromium against static servers: config present → `ws://<host>/gateway`; absent → `ws://<host>:8771`; `?ws=ws://elsewhere:1` → that; a malformed `"http://["` → `ws://<host>:8771` with the connect screen shown.
The app assumed its gateway sat on the page's own host at port 8771.
That is wrong for the deployment that needs the least setup: one HTTPS
origin whose reverse proxy serves the app and forwards a path to the
gateway, which saves a second certificate and port. A build-time value
was rejected because pointing a deployed app at another gateway should
not mean rebuilding it, so the app now reads `/config.json` beside it at
startup and falls back to the old default when the file is missing,
unreadable or slow. `?ws=` still overrides both.

The service worker already fetches everything outside `/assets/`
network-first with the cache as fallback, so a changed config lands on
the next launch and an offline launch still finds the last one.

The flake's module (NixOS or nix-darwin) writes that file next to the
built app and exposes the result as a document root, so a web server
can serve it without anyone hand-placing a file in the store.
natsukium deleted branch feat/same-origin-gateway 2026-10-14 13:23:49 +09:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
natsukium/felis-web!2
No description provided.