Spaces:
Sleeping
Sleeping
Caner Giden commited on
Refactor health check fetching in Home component
Browse files123123467856789101011121314151213141516172118192021222324252627282930253132333435async function fetchHealth() { const base = process.env.NEXT_PUBLIC_API_BASE; if (!base) return { error: "NEXT_PUBLIC_API_BASE missing" };export default async function Home() { let health: any;
try { const res = await fetch(`${base}/health`, { cache: "no-store" }); const data = await res.json(); return data; const res = await fetch("http://localhost:7860/api/core/health", { cache: "no-store", }); health = await res.json(); } catch (e: any) { return { error: e?.message ?? "fetch failed" }; health = { error: e?.message ?? "fetch failed" }; }}
export default async function Home() { const health = await fetchHealth();
return ( <main style={{ padding: 24 }}> <h1>ForgeFlow Studio</h1>
<p>Core health check:</p> <pre style={{ background: "#111", color: "#0f0", padding: 16, borderRadius: 8 }}>
<pre style={{ background: "#111", color: "#0f0", padding: 16, borderRadius: 8, }} > {JSON.stringify(health, null, 2)} </pre>
<p> Eğer burada <code>db_ok: true</code> görüyorsan Studio → Core bağlantısı tamam. Eğer burada <code>db_ok: true</code> görüyorsan Studio → Core bağlantısı tamam. </p> </main> );app/page.tsx+20-13