23 lines
739 B
TypeScript
23 lines
739 B
TypeScript
|
|
// app/api/bizportal-2/health/route.ts
|
||
|
|
// GET /api/bizportal-2/health — proxy to the Python service.
|
||
|
|
|
||
|
|
import { NextResponse } from "next/server";
|
||
|
|
|
||
|
|
export const dynamic = "force-dynamic";
|
||
|
|
export const revalidate = 0;
|
||
|
|
|
||
|
|
const SERVICE_URL = process.env.BIZPORTAL_SERVICE_URL ?? "http://127.0.0.1:7001";
|
||
|
|
|
||
|
|
export async function GET() {
|
||
|
|
try {
|
||
|
|
const res = await fetch(`${SERVICE_URL}/health`, { cache: "no-store" });
|
||
|
|
const data = await res.json().catch(() => ({ ok: false }));
|
||
|
|
return NextResponse.json(data, { status: res.ok ? 200 : 503 });
|
||
|
|
} catch (err: any) {
|
||
|
|
return NextResponse.json(
|
||
|
|
{ ok: false, error: `Python service not reachable at ${SERVICE_URL}: ${err.message ?? err}` },
|
||
|
|
{ status: 503 },
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|