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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user