diff --git a/src/app/favicon/[domain]/route.ts b/src/app/favicon/[domain]/route.ts index 84206ee..577e8c0 100644 --- a/src/app/favicon/[domain]/route.ts +++ b/src/app/favicon/[domain]/route.ts @@ -97,11 +97,27 @@ export async function GET(request: NextRequest, { params: { domain } }: { params }); } const iconResponse = await fetch(selectedIcon.href, { headers }); - const iconBuffer = await iconResponse.arrayBuffer(); - // Calculate execution time const endTime = Date.now(); const executionTime = endTime - startTime; + if (!iconResponse.ok) { + const firstLetter = domain.charAt(0).toUpperCase(); + const svgContent = ` + + + ${firstLetter} + + `; + return new Response(svgContent, { + status: 404, + headers: { + 'Cache-Control': 'public, max-age=86400', + 'Content-Type': 'image/svg+xml', + 'X-Execution-Time': `${executionTime}ms` + } + }); + } + const iconBuffer = await iconResponse.arrayBuffer(); // Return the image response with execution time return new Response(iconBuffer, {