fix(setup): print the hub's public URL, not the host the reader typed
Build and Deploy Remote Control Support / Test (push) Successful in 14s
Build and Deploy Remote Control Support / Build Image (push) Successful in 36s
Build and Deploy Remote Control Support / Deploy to Portainer (push) Successful in 6s

The setup pages build commands that get pasted into a terminal on a *different*
machine, but they built them from location.origin. Open the console by LAN IP or
over a tunnel and the enrolment one-liner told the target machine to curl an
address it may not resolve at all.

/docs and /enroll/:token are now served through a template that stamps in
config.baseUrl — PUBLIC_URL where set, the proxied request host otherwise — with
location.origin left as a fallback for the unsubstituted file. The remaining
127.0.0.1 references are the loopback VNC port on the machine being registered,
which is meant to be literal.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-12 11:41:31 -07:00
co-authored by Claude Opus 5
parent 1518211a17
commit 6895167964
3 changed files with 29 additions and 5 deletions
+18 -2
View File
@@ -120,9 +120,25 @@ app.get('/install.ps1', serveInstallScript('install.ps1', 'text/plain; charset=u
app.use('/novnc', express.static(NOVNC_DIR, { maxAge: '7d', immutable: true }));
app.use(express.static(PUBLIC_DIR));
// The setup pages print commands that get run on *another* machine, so they must
// name this hub's public address — not whatever host the reader happens to have
// typed. Reached over the LAN IP, `location.origin` would hand out a URL the
// target machine may not be able to resolve at all.
function sendPageWithHub(file) {
return (req, res) => {
let html;
try {
html = fs.readFileSync(path.join(PUBLIC_DIR, file), 'utf8');
} catch {
return res.status(500).type('text/plain').send(`${file} missing from this deployment`);
}
res.type('html').send(html.split('__HUB__').join(config.baseUrl(req)));
};
}
app.get('/viewer', (_req, res) => res.sendFile(path.join(PUBLIC_DIR, 'viewer.html')));
app.get('/docs', (_req, res) => res.sendFile(path.join(PUBLIC_DIR, 'docs.html')));
app.get('/enroll/:token', (_req, res) => res.sendFile(path.join(PUBLIC_DIR, 'enroll.html')));
app.get('/docs', sendPageWithHub('docs.html'));
app.get('/enroll/:token', sendPageWithHub('enroll.html'));
app.get('/s/:token', (_req, res) => res.sendFile(path.join(PUBLIC_DIR, 'share.html')));
app.use((req, res) => {