From fa6d775479551e11284ec7876d6c0c80b5e484f6 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 5 Jun 2023 16:02:18 +0200 Subject: [PATCH 1/3] Bail out of 404 page when favicon.ico doesn't exist --- packages/next/src/server/base-server.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index 8f8eaad0514ad..7a9ceaee6f7db 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -2371,6 +2371,14 @@ export default abstract class Server { ctx: RequestContext, err: Error | null ): Promise { + // Short-circuit favicon.ico in development to avoid compiling 404 page when the app has no favicon.ico. + // Since favicon.ico is automatically requested by the browser. + if (this.renderOpts.dev && ctx.pathname === '/favicon.ico') { + return { + type: 'html', + body: new RenderResult(''), + } + } const { res, query } = ctx try { let result: null | FindComponentsResult = null From d6ffbdbea51532501becd94b2c5f01a68cf93730 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 5 Jun 2023 16:06:14 +0200 Subject: [PATCH 2/3] Add favicon for hello-world tests --- test/e2e/app-dir/hello-world/app/favicon.ico | 0 test/e2e/hello-world/public/favicon.ico | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/e2e/app-dir/hello-world/app/favicon.ico create mode 100644 test/e2e/hello-world/public/favicon.ico diff --git a/test/e2e/app-dir/hello-world/app/favicon.ico b/test/e2e/app-dir/hello-world/app/favicon.ico new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/test/e2e/hello-world/public/favicon.ico b/test/e2e/hello-world/public/favicon.ico new file mode 100644 index 0000000000000..e69de29bb2d1d From 6d8b0a7597b5c939b87e78a9fe4ffe561863c2d9 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 5 Jun 2023 16:12:17 +0200 Subject: [PATCH 3/3] Fix favicon --- test/e2e/app-dir/hello-world/app/favicon.ico | Bin 0 -> 15086 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/e2e/app-dir/hello-world/app/favicon.ico b/test/e2e/app-dir/hello-world/app/favicon.ico index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4965832f2c9b0605eaa189b7c7fb11124d24e48a 100644 GIT binary patch literal 15086 zcmeHOOH5Q(7(R0cc?bh2AT>N@1PWL!LLfZKyG5c!MTHoP7_p!sBz0k$?pjS;^lmgJ zU6^i~bWuZYHL)9$wuvEKm~qo~(5=Lvx5&Hv;?X#m}i|`yaGY4gX+&b>tew;gcnRQA1kp zBbm04SRuuE{Hn+&1wk%&g;?wja_Is#1gKoFlI7f`Gt}X*-nsMO30b_J@)EFNhzd1QM zdH&qFb9PVqQOx@clvc#KAu}^GrN`q5oP(8>m4UOcp`k&xwzkTio*p?kI4BPtIwX%B zJN69cGsm=x90<;Wmh-bs>43F}ro$}Of@8)4KHndLiR$nW?*{Rl72JPUqRr3ta6e#A z%DTEbi9N}+xPtd1juj8;(CJt3r9NOgb>KTuK|z7!JB_KsFW3(pBN4oh&M&}Nb$Ee2 z$-arA6a)CdsPj`M#1DS>fqj#KF%0q?w50GN4YbmMZIoF{e1yTR=4ablqXHBB2!`wM z1M1ke9+<);|AI;f=2^F1;G6Wfpql?1d5D4rMr?#f(=hkoH)U`6Gb)#xDLjoKjp)1;Js@2Iy5yk zMXUqj+gyk1i0yLjWS|3sM2-1ECc;MAz<4t0P53%7se$$+5Ex`L5TQO_MMXXi04UDIU+3*7Ez&X|mj9cFYBXqM{M;mw_ zpw>azP*qjMyNSD4hh)XZt$gqf8f?eRSFX8VQ4Y+H3jAtvyTrXr`qHAD6`m;aYmH2zOhJC~_*AuT} zvUxC38|JYN94i(05R)dVKgUQF$}#cxV7xZ4FULqFCNX*Forhgp*yr6;DsIk=ub0Hv zpk2L{9Q&|uI^b<6@i(Y+iSxeO_n**4nRLc`P!3ld5jL=nZRw6;DEJ*1z6Pvg+eW|$lnnjO zjd|8>6l{i~UxI244CGn2kK@cJ|#ecwgSyt&HKA2)z zrOO{op^o*-