From 0ed6d8a1cf5eaa0d4bee0d627f99f69f9e4c3ea4 Mon Sep 17 00:00:00 2001 From: Muse Date: Wed, 21 Oct 2026 22:05:09 +0000 Subject: [PATCH] =?UTF-8?q?fix(nodes):=20agent=20=E4=B8=BB=E6=8E=A7?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=A2=84=E5=A1=AB=20origin+=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E8=B7=AF=E5=BE=84,=E5=9C=B0=E5=9D=80=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E4=B8=8D=E7=94=9F=E6=88=90=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E5=B9=B6=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/nodes/NodeFormModal.tsx | 29 +++++++++++++++---- frontend/src/pages/nodes/agentMasterUrl.ts | 20 +++++++++++++ frontend/src/test/agent-master-url.test.ts | 33 ++++++++++++++++++++++ internal/web/translation/ar-EG.json | 3 +- internal/web/translation/en-US.json | 3 +- internal/web/translation/es-ES.json | 3 +- internal/web/translation/fa-IR.json | 3 +- internal/web/translation/id-ID.json | 3 +- internal/web/translation/ja-JP.json | 3 +- internal/web/translation/pt-BR.json | 3 +- internal/web/translation/ru-RU.json | 3 +- internal/web/translation/tr-TR.json | 3 +- internal/web/translation/uk-UA.json | 3 +- internal/web/translation/vi-VN.json | 3 +- internal/web/translation/zh-CN.json | 3 +- internal/web/translation/zh-TW.json | 3 +- 16 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 frontend/src/pages/nodes/agentMasterUrl.ts create mode 100644 frontend/src/test/agent-master-url.test.ts diff --git a/frontend/src/pages/nodes/NodeFormModal.tsx b/frontend/src/pages/nodes/NodeFormModal.tsx index 0bb9d73..5aefab0 100644 --- a/frontend/src/pages/nodes/NodeFormModal.tsx +++ b/frontend/src/pages/nodes/NodeFormModal.tsx @@ -20,6 +20,7 @@ import type { Msg } from '@/utils'; import { NodeFormSchema, type NodeFormValues, type ProbeResult } from '@/schemas/node'; import { FormField, rhfZodValidate } from '@/components/form/rhf'; import { useOutboundTagGroups } from '@/api/queries/useOutboundTags'; +import { currentPanelMasterUrl } from './agentMasterUrl'; import './NodeFormModal.css'; type Mode = 'add' | 'edit'; @@ -248,8 +249,10 @@ export default function NodeFormModal({ if (agentMode && mode === 'add' && obj?.agentToken) { setAgentToken(obj.agentToken); setAgentNodeName(result.data.name.trim()); - // Default master URL to the current panel origin; user can edit it. - setAgentMasterUrl(window.location.origin); + // Default the master URL to the address this panel is being + // viewed through — origin AND base path. Dropping the base + // path made the agent's registration 404. User can edit it. + setAgentMasterUrl(currentPanelMasterUrl()); // Keep the modal open state; the token dialog shows on top. } else { onOpenChange(false); @@ -264,6 +267,13 @@ export default function NodeFormModal({ if (!submitting) onOpenChange(false); } + // The install command is only meaningful with a master URL; an empty + // one would produce a command that can never register, so withhold it + // (and say why) instead of letting the user copy a dead command. + const installCmd = agentMasterUrl + ? `bash <(curl -fL https://git.881218.xyz/rogue/3x-ui-agent/raw/branch/main/install-agent.sh) --master ${agentMasterUrl} --token ${agentToken ?? ''} --name ${agentNodeName}` + : ''; + return ( <> {messageContextHolder} @@ -560,9 +570,9 @@ export default function NodeFormModal({