fix: fallback localhost pour la version indexer (dev local)
Essaie INDEXER_BASE_URL, puis indexer:7081 (Docker), puis localhost:7081 (dev local) avec timeout 2s par tentative. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,14 +5,21 @@ import packageJson from "../../../package.json";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
async function fetchIndexerVersion(): Promise<string> {
|
||||
try {
|
||||
const indexerUrl = (process.env.INDEXER_BASE_URL || "http://indexer:7081").replace(/\/$/, "");
|
||||
const res = await fetch(`${indexerUrl}/version`, { signal: AbortSignal.timeout(3000) });
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
return data?.indexer ?? "?";
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
const urls = [
|
||||
process.env.INDEXER_BASE_URL,
|
||||
"http://indexer:7081",
|
||||
"http://localhost:7081",
|
||||
].filter(Boolean).map(u => u!.replace(/\/$/, ""));
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const res = await fetch(`${url}/version`, { signal: AbortSignal.timeout(2000) });
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
return data?.indexer ?? "?";
|
||||
}
|
||||
} catch { /* try next */ }
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user