25 lines
794 B
TypeScript
25 lines
794 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 { searchParams } = new URL(request.url);
|
||
|
|
const country = searchParams.get("country");
|
||
|
|
|
||
|
|
try {
|
||
|
|
const url = country
|
||
|
|
? `${COMMUNITY_URL}/api/v2/zakat/agents?country=${encodeURIComponent(country)}`
|
||
|
|
: `${COMMUNITY_URL}/api/v2/zakat/agents`;
|
||
|
|
|
||
|
|
const res = await fetch(url);
|
||
|
|
const data = await res.json();
|
||
|
|
return NextResponse.json(data, { status: res.status });
|
||
|
|
} catch (error) {
|
||
|
|
console.error("[zakat/agents] Proxy error:", error);
|
||
|
|
return NextResponse.json(
|
||
|
|
{ error: "Failed to fetch zakat agents" },
|
||
|
|
{ status: 502 }
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|