Fix: no more 404 console spam for missing sender favicons

/api/favicon returned 404 in three paths (negative cache hit, non-200
upstream, sub-10-byte body), and since the avatar loads it as <img src>,
the browser logged a red 404 for every sender domain without a public
favicon - dozens per inbox view. Now it returns HTTP 200 with a 1x1
transparent PNG and an X-Bulwark-Favicon: missing header. Avatar.tsx detects
the sentinel via naturalWidth <= 1 in onLoad and falls back to initials, so
behaviour is visually identical without the console noise.
This commit is contained in:
dealerweb
2026-05-30 16:58:46 +02:00
committed by Linus Rath
parent 1512b9afc0
commit 7ee329e046
2 changed files with 26 additions and 12 deletions
+9
View File
@@ -270,6 +270,15 @@ export function Avatar({ name, email, contactPhotoUri, size = "md", className, d
alt=""
className="w-full h-full object-cover"
onError={handleImgError}
// /api/favicon returns a 1x1 transparent PNG (HTTP 200) when no real
// favicon exists, to avoid spamming the DevTools console with 404s.
// Detect that sentinel by naturalWidth and fall back to initials.
onLoad={(e) => {
const img = e.currentTarget;
if (isFavicon && img.naturalWidth <= 1) {
handleImgError();
}
}}
/>
) : (
getInitials()