From 0afcc07642431f7d02fafcc61a90fb32c95d72e1 Mon Sep 17 00:00:00 2001 From: ypratama Date: Fri, 28 Aug 2026 17:04:33 +0700 Subject: [PATCH] Fix: Revert MongoDB connection logic to respect API key prefix to avoid network isolation issues in Swarm deployments --- src/lib/actions/agents.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/actions/agents.ts b/src/lib/actions/agents.ts index 05d4f76..4805f78 100644 --- a/src/lib/actions/agents.ts +++ b/src/lib/actions/agents.ts @@ -34,8 +34,8 @@ export async function getAgents(clientSiteUuid?: string): Promise { SITE_UUID = user.site_uuid; } - // All agent data comes from MongoDB agent_registry if MONGODB_URI is provided or API key is sk_db_ - if (process.env.MONGODB_URI || (API_KEY && API_KEY.startsWith("sk_db_"))) { + // All agent data comes from MongoDB agent_registry (single source of truth) + if (API_KEY && API_KEY.startsWith("sk_db_")) { const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/backone_dpi'; try { @@ -79,7 +79,7 @@ export async function getAgents(clientSiteUuid?: string): Promise { export async function getAgent(agentId: string): Promise { try { const API_KEY = getApiKey(); - if (process.env.MONGODB_URI || (API_KEY && API_KEY.startsWith("sk_db_"))) { + if (API_KEY && API_KEY.startsWith("sk_db_")) { const agents = await getAgents(); return agents.find(a => a.uuid === agentId || String(a.id) === agentId) || null; }