fix: use beforeFiles (#8276)

This commit is contained in:
Joseph
2026-01-30 14:28:43 +01:00
committed by GitHub
parent ec13a90a36
commit 24ec67ee2e

View File

@@ -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}) => {