From b7fb7daa4d60462121f4efe7f8960318e62f35a8 Mon Sep 17 00:00:00 2001 From: maikrolf <40924921+maikrolf@users.noreply.github.com> Date: Sat, 19 Sep 2026 17:39:06 +0200 Subject: [PATCH] debug: clone req body voor POST pins + verbose logging --- src/app/api/[...path]/proxy-ipfs.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/api/[...path]/proxy-ipfs.ts b/src/app/api/[...path]/proxy-ipfs.ts index df8f7e9..61e2ba3 100644 --- a/src/app/api/[...path]/proxy-ipfs.ts +++ b/src/app/api/[...path]/proxy-ipfs.ts @@ -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) {