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
|
||||
const p = path.replace(/^\/+/, '').replace(/\/+$/, '');
|
||||
|
||||
// ── Lokale pin opslag (altijd, ongeacht Kubo) ──
|
||||
// ── Lokale pin opslag (altijd) ──
|
||||
// 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/')) {
|
||||
console.log('[proxyIPFS] → handling locally');
|
||||
return handleLocalPins(p, method, req);
|
||||
}
|
||||
|
||||
// In dev, the Kubo API is behind nginx with Basic Auth.
|
||||
// If no KUBO_API_URL is configured, return a clear error.
|
||||
// IPFS routes gaan naar Kubo (wanneer beschikbaar)
|
||||
const kuboSvc = kuboApiUrl();
|
||||
if (!kuboSvc) {
|
||||
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 }
|
||||
);
|
||||
}
|
||||
@@ -106,10 +102,8 @@ async function handleLocalPins(path: string, method: string, req: NextRequest):
|
||||
// POST /api/pins — pin een CID
|
||||
if (p === 'pins' && method === 'POST') {
|
||||
try {
|
||||
// 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 });
|
||||
@@ -124,8 +118,7 @@ async function handleLocalPins(path: string, method: string, req: NextRequest):
|
||||
|
||||
await localAddPin(cid, name, size || 0);
|
||||
return NextResponse.json({ cid });
|
||||
} catch (e) {
|
||||
console.error('[handleLocalPins] POST error:', e);
|
||||
} catch {
|
||||
return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user