AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Next.Js 16 Static Export: RSC Payload Path Mismatch Causes 404 Errors On Prefetch

In Next.js 16.0.0–16.3.5 with `output: 'export'`, the generated RSC payload files use a directory-based path (`__next/page/__PAGE__.txt`), but the browser requests a flat dotted filename (`__next.page.__PAGE__.txt`), leading to 404 errors during link prefetching on statically exported sites.

highConfidence 87%Next.jsAffected V>=16.0.0 <=16.3.5

Origin Analysis

A breaking change in Next.js 16 RSC data loading introduced a path separator mismatch between the build output filesystem layout and the client-side URL construction, affecting static exports on all platforms.
1. Clone the reproduction repository: https://github.com/Aaakul/next16-next-link-rsc-issue 2. Run `cd next16` 3. Run `npm install` 4. Run `npm run build` (output: 'export' is already set in next.config.ts) 5. Run `npx serve out` 6. Visit `/next16` in a browser, open developer tools console, and click a link to navigate to `/next16/page`; observe 404 errors for RSC payload requests. 7. Compare with Next.js 15.5.6 (in `next15` folder) to confirm no such errors.

Fixing Code Block

Edge Case Audit

This is a stopgap hack that duplicates files, increasing deployment size. It may break if Next.js changes its RSC output naming or if the official fix is applied. The script only modifies static export output and will not work for server-rendered deployments. Test thoroughly on a staging environment before production. Rollback by deleting the generated dotted files and re-running the build without the script. On Windows, ensure the script handles forward slashes correctly as shown.

Ecosystem Topology