From e99dfe80e92ae7f3e2326d1748881aac12b0563b Mon Sep 17 00:00:00 2001 From: Chancellor Clark Date: Mon, 18 Nov 2024 11:50:13 -0500 Subject: [PATCH] fix(assets): check if favicon.ico is a file --- .changeset/tender-chicken-deliver.md | 5 +++++ packages/open-next/src/build/createAssets.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/tender-chicken-deliver.md diff --git a/.changeset/tender-chicken-deliver.md b/.changeset/tender-chicken-deliver.md new file mode 100644 index 000000000..bd2056e31 --- /dev/null +++ b/.changeset/tender-chicken-deliver.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/aws": patch +--- + +When copying over assets, check to see if favicon.ico is a file. In some cases favicon.ico is a folder that can contain a route handler. diff --git a/packages/open-next/src/build/createAssets.ts b/packages/open-next/src/build/createAssets.ts index 322d642af..2c9206c96 100644 --- a/packages/open-next/src/build/createAssets.ts +++ b/packages/open-next/src/build/createAssets.ts @@ -44,7 +44,9 @@ export function createStaticAssets(options: buildHelper.BuildOptions) { const faviconPath = path.join(appPath, appSrcPath, "favicon.ico"); - if (fs.existsSync(faviconPath)) { + // We need to check if the favicon is either a file or directory. + // If it's a directory, we assume it's a route handler and ignore it. + if (fs.existsSync(faviconPath) && fs.lstatSync(faviconPath).isFile()) { fs.copyFileSync(faviconPath, path.join(outputPath, "favicon.ico")); } }