Skip to content

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

Open
@taheramr

Description

@taheramr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.Not FoundRelated to the not-found.tsx file or the notFound() function.RedirectsRelated to redirecting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions