From 88e167bb78f70583c7599de63f913dc5667e569d Mon Sep 17 00:00:00 2001 From: Joseph Chamochumbi Date: Thu, 29 Jan 2026 00:47:46 +0100 Subject: [PATCH] fix: use beforeFiles --- next.config.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/next.config.js b/next.config.js index 7580eb944c4..f8ec196e131 100644 --- a/next.config.js +++ b/next.config.js @@ -20,26 +20,28 @@ const nextConfig = { reactCompiler: true, }, async rewrites() { - return [ - // Serve markdown when Accept header prefers text/markdown - // Useful for LLM agents - https://www.skeptrune.com/posts/use-the-accept-header-to-serve-markdown-instead-of-html-to-llms/ - { - source: '/:path*', - has: [ - { - type: 'header', - key: 'accept', - value: '(.*text/markdown.*)', - }, - ], - destination: '/api/md/:path*', - }, - // Explicit .md extension also serves markdown - { - source: '/:path*.md', - destination: '/api/md/:path*', - }, - ]; + return { + beforeFiles: [ + // Serve markdown when Accept header prefers text/markdown + // Useful for LLM agents - https://www.skeptrune.com/posts/use-the-accept-header-to-serve-markdown-instead-of-html-to-llms/ + { + source: '/:path((?!llms.txt).*)', + has: [ + { + type: 'header', + key: 'accept', + value: '(.*text/markdown.*)', + }, + ], + destination: '/api/md/:path*', + }, + // Explicit .md extension also serves markdown + { + source: '/:path*.md', + destination: '/api/md/:path*', + }, + ], + }; }, env: {}, webpack: (config, {dev, isServer, ...options}) => {