Skip to content

fix: exclude .txt files from markdown content negotiation rewrite#2610

Merged
Lotte-Verheyden merged 1 commit intomainfrom
fix-llms-txt-fetch
Mar 5, 2026
Merged

fix: exclude .txt files from markdown content negotiation rewrite#2610
Lotte-Verheyden merged 1 commit intomainfrom
fix-llms-txt-fetch

Conversation

@Lotte-Verheyden
Copy link
Member

Summary

  • 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 (llms-docs.txt, llms-integrations.txt, llms-self-hosting.txt) to return 404 because /md-src/llms.txt.md doesn't exist.
  • Many AI agent tools (e.g. Claude Code's WebFetch) use intermediary fetching services that send broad Accept headers including text/markdown, triggering this rewrite unintentionally.
  • Adds (?!.*\.txt$) to the regex so .txt files are always served directly from public/ regardless of Accept headers.

Reproducer: curl -H "Accept: text/markdown" https://langfuse.com/llms.txt → 404 (should be 200)

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.
@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
langfuse-docs Ready Ready Preview, Comment Mar 5, 2026 9:12pm

Request Review

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 5, 2026
@dosubot dosubot bot added auto-merge This PR is set to be merged bug Something isn't working labels Mar 5, 2026
@Lotte-Verheyden Lotte-Verheyden added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit ecb655e Mar 5, 2026
13 checks passed
@Lotte-Verheyden Lotte-Verheyden deleted the fix-llms-txt-fetch branch March 5, 2026 21:20
@dosubot dosubot bot removed the auto-merge This PR is set to be merged label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant