Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextJS in SSG requests invalid .txt resources when using the Link component #77486

Open
taheramr opened this issue Mar 25, 2025 · 0 comments
Open
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.

Comments

@taheramr
Copy link

taheramr commented Mar 25, 2025

Link to the code that reproduces this issue

https://github.com/taheramr/reproducing-nextjs-txt-404

To Reproduce

  1. Clone the repo
  2. Build the application
  3. npx serve out
  4. Open localhost and keep the dev tools opened
  5. Observe the network tab and the 404 error

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
@github-actions github-actions bot added 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. labels Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant