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'] }; }