@devries-cameron20 / t3code-1 / commits / 96bf54e293
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Serve fallback project favicon when no icon file is found

- return an inline SVG favicon instead of 404 when project/icon files are missing - add route test coverage for fallback response status and MIME type

Julius Marminge committed Mar 1, 2026 at 23:15 UTC 96bf54e293b40c62a49162cae8586f9867a868e3
2 files changed +23 -2
apps/server/src/projectFaviconRoute.test.ts
+12
@@ -152,4 +152,16 @@ describe("tryHandleProjectFaviconRequest", () => {
152 expect(response.body).toBe("<svg>brand-obj-order</svg>");
153 });
154 });
155 +
156 + it("serves a fallback favicon when no icon exists", async () => {
157 + const projectDir = makeTempDir("t3code-favicon-route-fallback-");
158 +
159 + await withRouteServer(async (baseUrl) => {
160 + const pathname = `/api/project-favicon?cwd=${encodeURIComponent(projectDir)}`;
161 + const response = await request(baseUrl, pathname);
162 + expect(response.statusCode).toBe(200);
163 + expect(response.contentType).toContain("image/svg+xml");
164 + expect(response.body).toContain('data-fallback="project-favicon"');
165 + });
166 + });
167 });
apps/server/src/projectFaviconRoute.ts
+11 -2
@@ -9,6 +9,8 @@ const FAVICON_MIME_TYPES: Record<string, string> = {
9 ".ico": "image/x-icon",
10 };
11
12 +const FALLBACK_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#6b728080" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-fallback="project-favicon"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2Z"/></svg>`;
13 +
14 // Well-known favicon paths checked in order.
15 const FAVICON_CANDIDATES = [
16 "favicon.svg",
@@ -85,6 +87,14 @@ function serveFaviconFile(filePath: string, res: http.ServerResponse): void {
87 });
88 }
89
90 +function serveFallbackFavicon(res: http.ServerResponse): void {
91 + res.writeHead(200, {
92 + "Content-Type": "image/svg+xml",
93 + "Cache-Control": "public, max-age=3600",
94 + });
95 + res.end(FALLBACK_FAVICON_SVG);
96 +}
97 +
98 export function tryHandleProjectFaviconRequest(url: URL, res: http.ServerResponse): boolean {
99 if (url.pathname !== "/api/project-favicon") {
100 return false;
@@ -118,8 +128,7 @@ export function tryHandleProjectFaviconRequest(url: URL, res: http.ServerRespons
128
129 const trySourceFiles = (index: number): void => {
130 if (index >= ICON_SOURCE_FILES.length) {
121 - res.writeHead(404, { "Content-Type": "text/plain" });
122 - res.end("No favicon found");
131 + serveFallbackFavicon(res);
132 return;
133 }
134 const sourceFile = path.join(projectCwd, ICON_SOURCE_FILES[index]!);