aigcfree (Discord DM) runs `magpie web --addr 0.0.0.0:3430` on an Ubuntu
server behind nginx, and opens it from a Windows PC. The chat tab showed
"127.0.0.1 refused to connect": boot.js sent the frame to 127.0.0.1, the
viewer's own PC. 0.1.1 (8a9680b) explains an SSH tunnel instead. With a
magpie that proxies a page's service, no tunnel is needed:
- package.json declares magpie.page.service {port: 3477, option: "port"},
the same port index.mjs listens on. magpie web then proxies the service
under the page's token (/_magpie/plugin/<token>/_magpie/service/) and the
bridge hands that address to the page as magpie.service.
- boot.js goes to magpie.service when it is an http(s) address. Without
one (the desktop window, or an older magpie) it behaves as 0.1.1: on
loopback it goes to 127.0.0.1, from another machine it explains the
tunnel.
- The chat client asks api/... by relative address (app.js, index.html,
library.mjs's icon URLs), so it works under the proxied path. Served
from 127.0.0.1:<port>/ these resolve as before.
The service still listens on 127.0.0.1 only, and still checks Host,
Origin and its token. magpie's proxy sets Host to 127.0.0.1:<port>.
Run: bun test packages/chat (16 pass) and bun scripts/check.mjs on mote.
Real: a sandbox magpie web on mote (0.0.0.0, LAN), this package installed
from a folder, a fake gateway. Playwright on the Windows box opened the
chat tab over the LAN in Chromium and WebKit, sent a message, and got the
streamed answer; the fake gateway logged both requests.
Broken by hand: the service branch in boot.js off, 2 tests red.
Not tried: behind a real nginx; the desktop window with this version (the
fallback is the 0.1.1 path, covered by the launcher tests).