fix: exclude .txt files from markdown content negotiation rewrite#2610
Merged
Lotte-Verheyden merged 1 commit intomainfrom Mar 5, 2026
Merged
fix: exclude .txt files from markdown content negotiation rewrite#2610Lotte-Verheyden merged 1 commit intomainfrom
Lotte-Verheyden merged 1 commit intomainfrom
Conversation
The beforeFiles rewrite in next.config.mjs rewrites any path to /md-src/<path>.md when the request includes Accept: text/markdown. This causes /llms.txt (and sub-files) to 404 because /md-src/llms.txt.md doesn't exist. Many AI agent tools send broad Accept headers that include text/markdown, triggering this rewrite unintentionally. Adding (?!.*\.txt$) to the regex ensures .txt files are always served directly from public/ regardless of Accept headers.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
beforeFilesrewrite innext.config.mjsrewrites any path to/md-src/<path>.mdwhen the request includesAccept: text/markdown. This causes/llms.txtand sub-files (llms-docs.txt,llms-integrations.txt,llms-self-hosting.txt) to return 404 because/md-src/llms.txt.mddoesn't exist.WebFetch) use intermediary fetching services that send broadAcceptheaders includingtext/markdown, triggering this rewrite unintentionally.(?!.*\.txt$)to the regex so.txtfiles are always served directly frompublic/regardless ofAcceptheaders.Reproducer:
curl -H "Accept: text/markdown" https://langfuse.com/llms.txt→ 404 (should be 200)