From f2bc0c1da1542cb0e895e676e1b34b26cc027e81 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 19:28:04 +0100 Subject: [PATCH] feat: enhance background refresh logging Add more detailed logging to diagnose background refresh issues: - Log the exact URL being called - Log whether secret is present - Better error handling for non-JSON responses - More detailed error messages This will help identify if the refresh endpoint is being called and why we're not seeing logs from it. --- api/article-og.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/article-og.ts b/api/article-og.ts index 1f3788c7..3d912e5d 100644 --- a/api/article-og.ts +++ b/api/article-og.ts @@ -68,7 +68,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { : `https://read.withboris.com` const refreshUrl = `${origin}/api/article-og-refresh?naddr=${encodeURIComponent(naddr)}` - console.log(`Triggering background refresh for ${naddr}`) + console.log(`Triggering background refresh for ${naddr}`, { url: refreshUrl, hasSecret: !!secret }) fetch(refreshUrl, { method: 'POST', @@ -76,11 +76,15 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { keepalive: true }) .then(async (resp) => { - const result = await resp.json().catch(() => ({})) - console.log(`Background refresh response for ${naddr}:`, { status: resp.status, result }) + try { + const result = await resp.json() + console.log(`Background refresh response for ${naddr}:`, { status: resp.status, result }) + } catch (e) { + console.log(`Background refresh response for ${naddr}:`, { status: resp.status, text: await resp.text().catch(() => 'failed to read') }) + } }) .catch((err) => { - console.error(`Background refresh failed for ${naddr}:`, err) + console.error(`Background refresh fetch failed for ${naddr}:`, err instanceof Error ? err.message : err) }) }