fix(links): use configured domain for panel copy/QR links on loopback

The panel's copy/QR share links are built client-side and fell back to window.location.hostname, so reaching the panel over an SSH tunnel (127.0.0.1/localhost) leaked localhost into the links - unlike the backend subscription path, which falls back to the configured Sub/Web Domain (issue #4829).

Expose webDomain/subDomain via /defaultSettings and add preferPublicHost: when the browser host is loopback, prefer the configured Sub Domain (then Web Domain) for share/QR links. An explicit node override or per-inbound listen still wins; a routable browser host is kept as-is.

Closes #4829
This commit is contained in:
MHSanaei
2026-06-02 22:52:44 +02:00
parent fcc6787a64
commit 6ee462ac8e
8 changed files with 66 additions and 8 deletions
@@ -9,6 +9,7 @@ import {
genWireguardConfigs,
genWireguardLinks,
isPostQuantumLink,
preferPublicHost,
} from '@/lib/xray/inbound-link';
import { inboundFromDb, type DbInboundLike } from '@/lib/xray/inbound-from-db';
import QrPanel from './QrPanel';
@@ -57,7 +58,7 @@ export default function QrCodeModal({
useEffect(() => {
if (!open || !dbInbound) return;
const inbound = inboundFromDb(dbInbound);
const fallbackHostname = window.location.hostname;
const fallbackHostname = preferPublicHost(window.location.hostname, subSettings?.publicHost ?? '');
if (inbound.protocol === Protocols.WIREGUARD) {
const peerRemark = client?.email
? `${dbInbound.remark}-${client.email}`