From c41e237c5cb1db1477b8ae57cccb5640537b5d53 Mon Sep 17 00:00:00 2001 From: Lotte Verheyden <48100308+Lotte-Verheyden@users.noreply.github.com> Date: Thu, 5 Mar 2026 13:04:12 -0800 Subject: [PATCH] fix: exclude .txt files from markdown content negotiation rewrite The beforeFiles rewrite in next.config.mjs rewrites any path to /md-src/.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. --- next.config.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/next.config.mjs b/next.config.mjs index 08aa3cee9..117196b67 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -158,9 +158,9 @@ const nextraConfig = withNextra({ }, // Content negotiation: /docs or /docs/observability/overview -> /md-src/... .md - // Excludes /api, /_next, and /md-src, and avoids double-appending .md. + // Excludes /api, /_next, md-src, .md files, and .txt files (served directly from public/). { - source: "/:path((?!api|_next|md-src)(?!.*\\.md$).*)", + source: "/:path((?!api|_next|md-src)(?!.*\\.md$)(?!.*\\.txt$).*)", has: [{ type: "header", key: "accept", value: ".*text/markdown.*" }], destination: "/md-src/:path.md", },