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({