From 629a1683b57bf8bd93af623a1c5cb672898201e0 Mon Sep 17 00:00:00 2001 From: iqubik Date: Sat, 28 Mar 2026 18:56:35 +0300 Subject: [PATCH] Update SubscriptionsPage.tsx url bug fixed --- client/src/pages/SubscriptionsPage.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/client/src/pages/SubscriptionsPage.tsx b/client/src/pages/SubscriptionsPage.tsx index a08373f..d7bf56f 100644 --- a/client/src/pages/SubscriptionsPage.tsx +++ b/client/src/pages/SubscriptionsPage.tsx @@ -78,6 +78,13 @@ const patchLink = function (link: string, newHost: string): string { const generateId = () => Math.random().toString(36).substring(7); +const getSubscriptionUrl = (uuid: string, tunnelId: string | number) => { + // Поскольку Nginx/Vite Proxy не используется, направляем запросы /bus/ жестко на порт 3000 бэкенда + const baseUrl = `${window.location.protocol}//${window.location.hostname}:3000`; + const tunnelPart = tunnelId !== 'main' ? `/${tunnelId}` : ''; + return `${baseUrl}/bus/${uuid}${tunnelPart}`; +}; + export default function SubscriptionsPage() { const [subs, setSubs] = useState([]); const [tunnels, setTunnels] = useState([]); @@ -341,14 +348,14 @@ export default function SubscriptionsPage() { <> navigator.clipboard.writeText(`${location.protocol}//${location.hostname}:${location.port}/bus/${sub.uuid}${selectedServer !== 'main' ? `/${selectedServer}` : ''}`)} + onClick={() => navigator.clipboard.writeText(getSubscriptionUrl(sub.uuid, selectedServer))} title="Копировать ссылку" > window.open(`${location.protocol}//${location.hostname}:${location.port}/bus/${sub.uuid}${selectedServer !== 'main' ? `/${selectedServer}` : ''}`, '_blank')} + onClick={() => window.open(getSubscriptionUrl(sub.uuid, selectedServer), '_blank')} title="Открыть подписку" > @@ -376,13 +383,13 @@ export default function SubscriptionsPage() { transformOrigin={{ vertical: 'top', horizontal: 'right' }} > {isMobile && activeSub && ( - navigator.clipboard.writeText(`${location.protocol}//${location.hostname}:${location.port}/bus/${activeSub.uuid}${selectedServer !== 'main' ? `/${selectedServer}` : ''}`)}> + navigator.clipboard.writeText(getSubscriptionUrl(activeSub.uuid, selectedServer))}> Копировать ссылку )} {isMobile && activeSub && ( - window.open(`${location.protocol}//${location.hostname}:${location.port}/bus/${activeSub.uuid}${selectedServer !== 'main' ? `/${selectedServer}` : ''}`, '_blank')}> + window.open(getSubscriptionUrl(activeSub.uuid, selectedServer), '_blank')}> Открыть подписку