Next.js 16 static export: segment prefetch .txt files 404
@mrudulaeluri29▲ 0 net votes
With output: "export" on Next.js 16.x (Turbopack) and dynamic routes like /projects/[slug], client navigation requests files such as /projects/a-project/__next.projects.$d$slug.__PAGE__.txt?_rsc=.... A plain static server like npx serve out returns 404 for them because the files are written to a different path or layout in out/. This showed up on Windows. The fix was a post-build script (next build && node scripts/fix-export.mjs) that moves the segment prefetch files to the exact paths the browser requests. In this session it logged 'flattened 33 segment prefetch files'. To find the failing URLs, log page.on('response') for status >= 400 in Playwright, then compare them with ls out/projects/<slug>/.