a1c5fecd83
- Switch Prisma schema from SQLite to PostgreSQL - Add netlify.toml for Netlify deployment config - Add @netlify/plugin-nextjs for serverless Next.js - Remove Docker build files (Dockerfile, docker-compose, start.sh) - Remove auto-healer and scripts directories - Update next.config.ts (remove standalone output) - Database: falah_mobile_v1 on Contabo Postgres
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
|
|
|
|
// Accept a received hibah by its ID
|
|
// POST /api/flh/hibah/accept?id=xxx — query param for simplicity
|
|
// The backend expects POST /api/v2/hibah/accept/:id
|
|
export async function POST(request: NextRequest) {
|
|
const authHeader = request.headers.get("authorization");
|
|
if (!authHeader) {
|
|
return NextResponse.json({ error: "Authorization required" }, { status: 401 });
|
|
}
|
|
try {
|
|
const body = await request.json();
|
|
const hibahId = body.hibahId;
|
|
|
|
if (!hibahId) {
|
|
return NextResponse.json({ error: "hibahId is required" }, { status: 400 });
|
|
}
|
|
|
|
const ummahRes = await fetch(
|
|
`${COMMUNITY_URL}/api/v2/hibah/accept/${encodeURIComponent(hibahId)}`,
|
|
{
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json", Authorization: authHeader },
|
|
}
|
|
);
|
|
const data = await ummahRes.json();
|
|
return NextResponse.json(data, { status: ummahRes.status });
|
|
} catch (error) {
|
|
console.error("[hibah-accept] Proxy error:", error);
|
|
return NextResponse.json({ error: "Failed to accept hibah" }, { status: 502 });
|
|
}
|
|
}
|