From a7aa9307594c363346c684a4c16e1a53d35bb8df Mon Sep 17 00:00:00 2001 From: gbanyan Date: Thu, 20 Nov 2025 16:27:34 +0800 Subject: [PATCH] Fix search hanging on production by correcting Pagefind file path Problem: Search modal hangs on loading in production deployment, but works fine locally. Root cause: The Pagefind route handler was reading files from .next/pagefind, which is not reliably accessible in production deployments. The build script copies Pagefind files to public/_pagefind for deployment, but the route wasn't using them. Solution: Changed the file path in app/pagefind/[...path]/route.ts from .next/pagefind to public/_pagefind. Files in the public directory are always accessible and properly deployed. This ensures search works consistently across both development and production environments. --- app/pagefind/[...path]/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pagefind/[...path]/route.ts b/app/pagefind/[...path]/route.ts index fa451b8..982e9bc 100644 --- a/app/pagefind/[...path]/route.ts +++ b/app/pagefind/[...path]/route.ts @@ -8,7 +8,7 @@ export async function GET( ) { try { const { path } = await params; - const filePath = join(process.cwd(), '.next', 'pagefind', ...path); + const filePath = join(process.cwd(), 'public', '_pagefind', ...path); // Read the file const file = await readFile(filePath);