cleanup: verwijder debug logging uit proxy-ipfs
- Lokale pin opslag stabiel - Geen console.log meer - 191 tests passing
This commit is contained in:
@@ -6,21 +6,17 @@ export async function proxyIPFS(path: string, method: string, req: NextRequest):
|
|||||||
// Normalize path — verwijder leading/trailing slashes
|
// Normalize path — verwijder leading/trailing slashes
|
||||||
const p = path.replace(/^\/+/, '').replace(/\/+$/, '');
|
const p = path.replace(/^\/+/, '').replace(/\/+$/, '');
|
||||||
|
|
||||||
// ── Lokale pin opslag (altijd, ongeacht Kubo) ──
|
// ── Lokale pin opslag (altijd) ──
|
||||||
// Pins worden lokaal opgeslagen in .data/pins.json
|
// Pins worden lokaal opgeslagen in .data/pins.json
|
||||||
// Kubo wordt later toegevoegd voor productie
|
|
||||||
console.log('[proxyIPFS] path:', path, '→ normalized:', p, 'method:', method);
|
|
||||||
if (p === 'pins' || p.startsWith('pins/')) {
|
if (p === 'pins' || p.startsWith('pins/')) {
|
||||||
console.log('[proxyIPFS] → handling locally');
|
|
||||||
return handleLocalPins(p, method, req);
|
return handleLocalPins(p, method, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In dev, the Kubo API is behind nginx with Basic Auth.
|
// IPFS routes gaan naar Kubo (wanneer beschikbaar)
|
||||||
// If no KUBO_API_URL is configured, return a clear error.
|
|
||||||
const kuboSvc = kuboApiUrl();
|
const kuboSvc = kuboApiUrl();
|
||||||
if (!kuboSvc) {
|
if (!kuboSvc) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'IPFS proxy not configured', detail: 'Set KUBO_API_URL in env for dev, or use nginx routing in production' },
|
{ error: 'IPFS proxy not configured', detail: 'Set KUBO_API_URL in env' },
|
||||||
{ status: 501 }
|
{ status: 501 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -106,10 +102,8 @@ async function handleLocalPins(path: string, method: string, req: NextRequest):
|
|||||||
// POST /api/pins — pin een CID
|
// POST /api/pins — pin een CID
|
||||||
if (p === 'pins' && method === 'POST') {
|
if (p === 'pins' && method === 'POST') {
|
||||||
try {
|
try {
|
||||||
// Clone de request om body te lezen (voorkomt "body already consumed")
|
|
||||||
const clonedReq = req.clone();
|
const clonedReq = req.clone();
|
||||||
const text = await clonedReq.text();
|
const text = await clonedReq.text();
|
||||||
console.log('[handleLocalPins] POST body:', text);
|
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return NextResponse.json({ error: 'Empty body' }, { status: 400 });
|
return NextResponse.json({ error: 'Empty body' }, { status: 400 });
|
||||||
@@ -124,8 +118,7 @@ async function handleLocalPins(path: string, method: string, req: NextRequest):
|
|||||||
|
|
||||||
await localAddPin(cid, name, size || 0);
|
await localAddPin(cid, name, size || 0);
|
||||||
return NextResponse.json({ cid });
|
return NextResponse.json({ cid });
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error('[handleLocalPins] POST error:', e);
|
|
||||||
return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
|
return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user