fix(engine-room): usa 127.0.0.1 e adiciona logs

- Troca localhost por 127.0.0.1 (mais confiável)
- Adiciona logs para debugar chamadas ao Registry

Refs: engine-room, registry, debug
This commit is contained in:
Jonas Pacheco 2026-04-08 11:47:21 -03:00
parent fcfce87df8
commit b0a8e73f67
1 changed files with 11 additions and 4 deletions

View File

@ -13,17 +13,24 @@ async function fetchRegistryServices(): Promise<any[] | null> {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
const response = await fetch('http://localhost:5001/api/registry/services', {
// Tenta 127.0.0.1 primeiro (mais confiável que localhost)
const response = await fetch('http://127.0.0.1:5001/api/registry/services', {
signal: controller.signal,
});
clearTimeout(timeout);
if (!response.ok) return null;
if (!response.ok) {
console.log('[Engine Room] Registry retornou:', response.status);
return null;
}
const data = await response.json();
return data.success && Array.isArray(data.data?.services) ? data.data.services : null;
} catch {
const services = data.success && Array.isArray(data.data?.services) ? data.data.services : null;
console.log(`[Engine Room] Registry retornou ${services?.length || 0} serviços`);
return services;
} catch (error) {
console.error('[Engine Room] Erro ao consultar Registry:', error);
return null;
}
}