debug: clone req body voor POST pins + verbose logging
This commit is contained in:
@@ -106,11 +106,22 @@ async function handleLocalPins(path: string, method: string, req: NextRequest):
|
||||
// POST /api/pins — pin een CID
|
||||
if (p === 'pins' && method === 'POST') {
|
||||
try {
|
||||
// Lees body als text, dan parse als JSON (voorkomt "body already read" issues)
|
||||
const text = await req.text();
|
||||
const body = text ? JSON.parse(text) : {};
|
||||
// Clone de request om body te lezen (voorkomt "body already consumed")
|
||||
const clonedReq = req.clone();
|
||||
const text = await clonedReq.text();
|
||||
console.log('[handleLocalPins] POST body:', text);
|
||||
|
||||
if (!text) {
|
||||
return NextResponse.json({ error: 'Empty body' }, { status: 400 });
|
||||
}
|
||||
|
||||
const body = JSON.parse(text);
|
||||
const { cid, name, size } = body;
|
||||
if (!cid) return NextResponse.json({ error: 'cid required' }, { status: 400 });
|
||||
|
||||
if (!cid) {
|
||||
return NextResponse.json({ error: 'cid required' }, { status: 400 });
|
||||
}
|
||||
|
||||
await localAddPin(cid, name, size || 0);
|
||||
return NextResponse.json({ cid });
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user