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";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
async function fetchIndexerVersion(): Promise<string> {
|
async function fetchIndexerVersion(): Promise<string> {
|
||||||
try {
|
const urls = [
|
||||||
const indexerUrl = (process.env.INDEXER_BASE_URL || "http://indexer:7081").replace(/\/$/, "");
|
process.env.INDEXER_BASE_URL,
|
||||||
const res = await fetch(`${indexerUrl}/version`, { signal: AbortSignal.timeout(3000) });
|
"http://indexer:7081",
|
||||||
if (res.ok) {
|
"http://localhost:7081",
|
||||||
const data = await res.json();
|
].filter(Boolean).map(u => u!.replace(/\/$/, ""));
|
||||||
return data?.indexer ?? "?";
|
|
||||||
}
|
for (const url of urls) {
|
||||||
} catch { /* ignore */ }
|
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 "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user