From 56c208f7c959062b38aef0d6447758dfa4cc432c Mon Sep 17 00:00:00 2001 From: ypratama Date: Wed, 2 Sep 2026 15:39:57 +0700 Subject: [PATCH] Fix: Prevent Next.js env inlining and handle test-site in agentsMongo --- src/lib/actions/agentsMongo.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/actions/agentsMongo.ts b/src/lib/actions/agentsMongo.ts index cb5af8b..b867f11 100644 --- a/src/lib/actions/agentsMongo.ts +++ b/src/lib/actions/agentsMongo.ts @@ -14,8 +14,10 @@ export async function fetchAgentsFromMongo( const filter: any = {}; if (!isCompanyRole && SITE_UUID) { - if (SITE_UUID === 'all') { - const envSites = (process.env.BACKONE_SITE_UUIDS || process.env.BACKONE_SITE_UUID || '').split(',').map(s => s.trim()).filter(Boolean); + if (SITE_UUID === 'all' || SITE_UUID === 'test-site' || SITE_UUID === 'default') { + // Use dynamic env access to prevent Next.js from inlining undefined during docker build + const dynamicEnv = process['env']; + const envSites = (dynamicEnv.BACKONE_SITE_UUIDS || dynamicEnv.BACKONE_SITE_UUID || '').split(',').map(s => s.trim()).filter(Boolean); if (envSites.length > 0) { filter.site_uuid = { $in: [...envSites, 'global'] }; }