favicon.blueat.net#
A small Cloudflare Worker that fetches a website’s favicon by domain, caches responses at the edge, and returns the image (or a redirect fallback).
Quick start#
npm install
npm run dev
Open http://localhost:8787/example.com while dev is running.
Deploy:
npx wrangler login # once per machine
npm run deploy
Edit wrangler.toml and set name to the Worker name you want in Cloudflare.
Usage#
Request path is the domain (no protocol):
| URL | Meaning |
|---|---|
/{domain} |
Resolve favicon for domain |
Query parameters
| Param | Effect |
|---|---|
larger=true |
Prefer larger icons (e.g. Google s2 at 128px, SVG, or big apple-touch sizes from HTML) |
default-avatar=<url> |
If no favicon is found, 302 redirect to this URL |
throw-error-on-404=true |
If no favicon is found, return 404 instead of redirecting |
Successful responses include Cache-Control, Access-Control-Allow-Origin: *, and X-Favicon-Source describing where the icon came from.
How it works#
- Check the Workers cache for this domain (and
largerflag). - If
larger, try Google’s favicon service at 128px. - Otherwise fetch the site HTML and parse
<link rel="icon">/ apple-touch-icon tags. - Fall back to
/favicon.ico, then Google’s 32px favicon. - If nothing works, redirect to a default image or your
default-avatar, or404when requested.
Files#
worker.js— Worker entrypointwrangler.toml— Wrangler project config
License#
Use and modify as you like for your own deployment.