From d35c47e444e4a27bace3471e5f377a1fef9e996a Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 29 Feb 2024 23:30:36 +0800 Subject: [PATCH] fix: favicon not found (#14598) --- lib/routes.test.ts | 6 ++++++ lib/routes.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/routes.test.ts b/lib/routes.test.ts index 6edc3cdc7..967297648 100644 --- a/lib/routes.test.ts +++ b/lib/routes.test.ts @@ -79,4 +79,10 @@ describe('router', () => { expect(await response.text()).toBe('User-agent: *\nDisallow: /'); expect(response.headers.get('content-type')).toBe('text/plain'); }); + + // favicon.ico + it('/favicon.ico', async () => { + const response = await app.request('/favicon.ico'); + expect(response.status).toBe(200); + }); }); diff --git a/lib/routes.ts b/lib/routes.ts index 6470201d7..4c5406130 100644 --- a/lib/routes.ts +++ b/lib/routes.ts @@ -48,6 +48,7 @@ export default function (app: Hono) { '/*', serveStatic({ root: './lib/assets', + rewriteRequestPath: (path) => (path === '/favicon.ico' ? '/favicon.png' : path), }) ); }