import { NextRequest, NextResponse } from "next/server";

const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";

export async function GET() {
  try {
    const ummahRes = await fetch(`${COMMUNITY_URL}/api/v2/sadaqah/causes`);
    const data = await ummahRes.json();
    return NextResponse.json(data, { status: ummahRes.status });
  } catch (error) {
    console.error("[sadaqah-causes] Proxy error:", error);
    return NextResponse.json({ error: "Failed to fetch causes" }, { status: 502 });
  }
}
