// app/api/demo/create-customer/route.ts
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const body = await request.json();
// Server-side: call CrediBill API using secret key
const response = await fetch(
"https://giant-goldfish-922.convex.site/api/customers",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CREDIBILL_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
const data = await response.json();
if (!response.ok) {
return NextResponse.json({ error: data }, { status: response.status });
}
return NextResponse.json(data);
}