diff --git a/backend/routes/appDetailsDpiHelper.js b/backend/routes/appDetailsDpiHelper.js index 5b41d06..117f068 100644 --- a/backend/routes/appDetailsDpiHelper.js +++ b/backend/routes/appDetailsDpiHelper.js @@ -70,7 +70,7 @@ async function populateAppCache(BASE_URL, token, siteUuid) { // Core DPI fetch for app-details async function fetchFromDpiApi(label, agentUuid, timeRange, token, siteUuid) { - const BASE_URL = process.env.BACKONE_INFORMATICS_BASE_URL || 'https://api0.dev.backone.cloud/api/v1'; + const BASE_URL = process.env.BACKONE_INFORMATICS_BASE_URL || process.env.NETIFY_INFORMATICS_BASE_URL || 'https://api0.dev.backone.cloud/api/v1'; const headers = { 'x-api-key': token, 'Accept': 'application/json', 'x-net-site': siteUuid }; const TIMEOUT_MS = 12000; diff --git a/backend/routes/appDetailsHandler.js b/backend/routes/appDetailsHandler.js index 1325ec6..a6a6f7a 100644 --- a/backend/routes/appDetailsHandler.js +++ b/backend/routes/appDetailsHandler.js @@ -20,8 +20,8 @@ module.exports = async function appDetailsHandler(req, res, helpers) { const label = String(req.query.label ?? ''); if (!label) return res.status(400).json({ ok: false, message: 'label required' }); - const token = process.env.BACKONE_DPI_API_KEY || process.env.BACKONE_TOKEN; - const SITE_UUID = process.env.BACKONE_SITE_UUID; + const token = process.env.BACKONE_DPI_API_KEY || process.env.NETIFY_API_KEY || process.env.BACKONE_TOKEN || process.env.NETIFY_TOKEN; + const SITE_UUID = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID; // Respect timeRange from request const timeFilter = getTimeFilter(req); @@ -39,7 +39,7 @@ module.exports = async function appDetailsHandler(req, res, helpers) { if (deviceApps.length > 0) { // Pre-load application lookup to resolve default domains - const BASE_URL = process.env.BACKONE_INFORMATICS_BASE_URL || 'https://api0.dev.backone.cloud/api/v1'; + const BASE_URL = process.env.BACKONE_INFORMATICS_BASE_URL || process.env.NETIFY_INFORMATICS_BASE_URL || 'https://api0.dev.backone.cloud/api/v1'; if (token && SITE_UUID) { await populateAppCache(BASE_URL, token, SITE_UUID).catch(e => console.warn('[AppDetails] Cache error:', e.message)); } diff --git a/backend/routes/auth/seed.js b/backend/routes/auth/seed.js index 20da709..0c158e8 100644 --- a/backend/routes/auth/seed.js +++ b/backend/routes/auth/seed.js @@ -17,7 +17,7 @@ async function seedAuth() { password_hash: hash, account_name: 'BackOne Administrator', role: 'SUPER_ADMIN', - site_uuid: process.env.BACKONE_SITE_UUID || null, + site_uuid: process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID || null, agent_uuid: null, }); console.log('[Auth] ✓ Default SUPER_ADMIN created: admin / admin'); diff --git a/backend/routes/auth/usersCreateExternal.js b/backend/routes/auth/usersCreateExternal.js index 540d623..40f0a0a 100644 --- a/backend/routes/auth/usersCreateExternal.js +++ b/backend/routes/auth/usersCreateExternal.js @@ -57,8 +57,8 @@ async function handleCreateExternalUser(req, res) { const siteUuid = (role === 'EXECUTIVE' || role === 'COMPANY_ADMIN') ? null : req.adminUser.role === 'SUPER_ADMIN' - ? (req.body.site_uuid || process.env.BACKONE_SITE_UUID || null) - : req.adminUser.site_uuid; + ? (req.body.site_uuid || process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID) + : (req.body.site_uuid || null); const createdBy = req.adminUser.role === 'SUPER_ADMIN' ? (req.body.created_by || req.adminUser.username) diff --git a/backend/routes/auth/usersHelper.js b/backend/routes/auth/usersHelper.js index 484431b..f27c5c5 100644 --- a/backend/routes/auth/usersHelper.js +++ b/backend/routes/auth/usersHelper.js @@ -23,7 +23,7 @@ async function resolveSiteUuidForAgent(agentUuid, fallbackSiteUuid, adminUser, b if (!siteUuid) { siteUuid = adminUser.role === 'SUPER_ADMIN' - ? (bodySiteUuid || process.env.BACKONE_SITE_UUID || fallbackSiteUuid || null) + ? (bodySiteUuid || process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID) : adminUser.site_uuid; } diff --git a/backend/routes/dashboard/agentLocations.js b/backend/routes/dashboard/agentLocations.js index f9ef3e4..93dc563 100644 --- a/backend/routes/dashboard/agentLocations.js +++ b/backend/routes/dashboard/agentLocations.js @@ -54,7 +54,7 @@ router.post('/agent-locations', async (req, res) => { siteUuid = summaryDoc.site_uuid; } else { // Fallback or use standard env site_uuid - siteUuid = process.env.BACKONE_SITE_UUID || '6681452d_9cae_4ff4_8ae8_0d504774265e'; + siteUuid = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID || '6681452d_9cae_4ff4_8ae8_0d504774265e'; } } diff --git a/src/lib/actions/agents.ts b/src/lib/actions/agents.ts index 1643eb5..08ed7f0 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 (single source of truth) - if (API_KEY && API_KEY.startsWith("sk_db_")) { + // 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_"))) { 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 (API_KEY && API_KEY.startsWith("sk_db_")) { + if (process.env.MONGODB_URI || (API_KEY && API_KEY.startsWith("sk_db_"))) { const agents = await getAgents(); return agents.find(a => a.uuid === agentId || String(a.id) === agentId) || null; } diff --git a/src/lib/actions/agentsCore.ts b/src/lib/actions/agentsCore.ts index 5a3464e..1858a9d 100644 --- a/src/lib/actions/agentsCore.ts +++ b/src/lib/actions/agentsCore.ts @@ -1,11 +1,11 @@ import { revalidatePath } from "next/cache"; -export const BASE_URL = process.env.BACKONE_BASE_URL || process.env.BACKONE_INFORMATICS_BASE_URL || "http://127.0.0.1:3011"; +export const BASE_URL = process.env.BACKONE_BASE_URL || process.env.NETIFY_BASE_URL || process.env.BACKONE_INFORMATICS_BASE_URL || process.env.NETIFY_INFORMATICS_BASE_URL || "http://127.0.0.1:3011"; export const API_URL = `${BASE_URL}/assets/agents`; -export const getApiKey = () => process.env.BACKONE_API_KEY || process.env.BACKONE_DPI_API_KEY; -export const getJwtToken = () => process.env.BACKONE_JWT_TOKEN || process.env.BACKONE_TOKEN; -export const getSiteUuid = () => process.env.BACKONE_SITE_UUID; +export const getApiKey = () => process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY || process.env.BACKONE_DPI_API_KEY || process.env.NETIFY_DPI_API_KEY; +export const getJwtToken = () => process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN || process.env.BACKONE_TOKEN || process.env.NETIFY_TOKEN; +export const getSiteUuid = () => process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID; export interface Agent { id: number;