fix(routing): _previewUrl uses port.subdomain, not the retired HOST_NAME

routing-manager.js read CFG_<APP>_HOST_NAME for its preview URL, but that
key was retired by the per-port subdomain refactor (2e4f420, 2026-05-22)
and no .config defines it anymore. The lookup always returned undefined,
so even with a configured domain the preview fell through to the
`<your-domain>` placeholder instead of showing the real host.

Now derives the preview from the port's own subdomain (parts[10] of
the 12-col PORT row), matching the canonical host_setup rule in
scripts/network/variables/variables_init_app.sh:
  @ / root      -> apex (`https://<domain>`)
  set           -> `https://<sub>.<domain>`
  empty         -> `https://<app>.<domain>`

Also adds `subdomain` to the port object emitted by _collectPorts so
this and any future per-row consumer can read it.

Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
librelad 2026-05-27 13:23:47 +01:00
parent e46c619d82
commit 9d5d0103b6

View File

@ -59,6 +59,7 @@ class RoutingManager {
protocol: parts[4] || 'tcp',
traefik: isNine ? parts[6] === 'true' : parts[5] === 'true',
webui,
subdomain: isTwelve ? (parts[10] || '') : '',
recommended: isTwelve ? parts[11] === 'true' : webui,
description: isNine ? (parts[8] || '') : (parts[7] || '')
};
@ -70,11 +71,14 @@ class RoutingManager {
}
_previewUrl(port, app) {
const hostName = app && app.config && app.config[`CFG_${port.appSlug.toUpperCase()}_HOST_NAME`];
const domainIdx = app && app.config && app.config[`CFG_${port.appSlug.toUpperCase()}_DOMAIN`];
const domain = app && app.config && app.config[`CFG_DOMAIN_${domainIdx || 1}`];
if (hostName && domain) return `https://${hostName}.${domain}`;
return `https://${port.appSlug}.<your-domain>`;
const sub = (port.subdomain || '').trim();
const placeholder = '<your-domain>';
const base = domain || placeholder;
if (sub === '@' || sub === 'root') return `https://${base}`;
if (sub) return `https://${sub}.${base}`;
return `https://${port.appSlug}.${base}`;
}
_render() {