fix: local pin POST body lezing - lees als text voordat JSON parse
This commit is contained in:
@@ -106,12 +106,15 @@ async function handleLocalPins(path: string, method: string, req: NextRequest):
|
||||
// POST /api/pins — pin een CID
|
||||
if (p === 'pins' && method === 'POST') {
|
||||
try {
|
||||
const body = await req.json();
|
||||
// Lees body als text, dan parse als JSON (voorkomt "body already read" issues)
|
||||
const text = await req.text();
|
||||
const body = text ? JSON.parse(text) : {};
|
||||
const { cid, name, size } = body;
|
||||
if (!cid) return NextResponse.json({ error: 'cid required' }, { status: 400 });
|
||||
await localAddPin(cid, name, size || 0);
|
||||
return NextResponse.json({ cid });
|
||||
} catch {
|
||||
} catch (e) {
|
||||
console.error('[handleLocalPins] POST error:', e);
|
||||
return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user