NextJS in SSG requests invalid .txt
resources when using the Link component
#77486
Labels
Linking and Navigating
Related to Next.js linking (e.g., <Link>) and navigation.
Not Found
Related to the not-found.tsx file or the notFound() function.
Redirects
Related to redirecting.
Link to the code that reproduces this issue
https://github.com/taheramr/reproducing-nextjs-txt-404
To Reproduce
npx serve out
Current vs. Expected behavior
When adding a resource to NextJS in its public directory, this resource can be some other assets built from another package for example and when trying to route to that resource (index.html) NextJS tries to prefetch that resource by appending a
.txt
to the resource path which casues a 404.The expected behavior that nextjs does not prefetch it.
Provide environment information
Happens in pretty much every operating system.
Which area(s) are affected? (Select all that apply)
Not Found, Redirects, Linking and Navigating
Which stage(s) are affected? (Select all that apply)
next build (local), Vercel (Deployed), Other (Deployed)
Additional context
I tested the issue with multiple NextJS versions (14 & 15). This is happening in our own website https://cloudscape.design/demos/, if you clicked on one link on the side navigation it will link you to an html pre-generated page. NextJS creates an additional request with a
.txt
and appends it which causes a 404 and overwhelms our reporting tools.2025-03-25_01-57-01.2.mp4
The text was updated successfully, but these errors were encountered: