21 lines
796 B
TypeScript
21 lines
796 B
TypeScript
|
|
import { NextRequest, NextResponse } from "next/server";
|
||
|
|
|
||
|
|
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
|
||
|
|
|
||
|
|
export async function GET(request: NextRequest) {
|
||
|
|
const authHeader = request.headers.get("authorization");
|
||
|
|
if (!authHeader) {
|
||
|
|
return NextResponse.json({ error: "Authorization required" }, { status: 401 });
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
const ummahRes = await fetch(`${COMMUNITY_URL}/api/v2/hibah/summary`, {
|
||
|
|
headers: { Authorization: authHeader },
|
||
|
|
});
|
||
|
|
const data = await ummahRes.json();
|
||
|
|
return NextResponse.json(data, { status: ummahRes.status });
|
||
|
|
} catch (error) {
|
||
|
|
console.error("[hibah-summary] Proxy error:", error);
|
||
|
|
return NextResponse.json({ error: "Failed to fetch hibah summary" }, { status: 502 });
|
||
|
|
}
|
||
|
|
}
|