Skip to content

Commit 88e167b

Browse files
committed
fix: use beforeFiles
1 parent a2a19ba commit 88e167b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

next.config.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,28 @@ const nextConfig = {
2020
reactCompiler: true,
2121
},
2222
async rewrites() {
23-
return [
24-
// Serve markdown when Accept header prefers text/markdown
25-
// Useful for LLM agents - https://www.skeptrune.com/posts/use-the-accept-header-to-serve-markdown-instead-of-html-to-llms/
26-
{
27-
source: '/:path*',
28-
has: [
29-
{
30-
type: 'header',
31-
key: 'accept',
32-
value: '(.*text/markdown.*)',
33-
},
34-
],
35-
destination: '/api/md/:path*',
36-
},
37-
// Explicit .md extension also serves markdown
38-
{
39-
source: '/:path*.md',
40-
destination: '/api/md/:path*',
41-
},
42-
];
23+
return {
24+
beforeFiles: [
25+
// Serve markdown when Accept header prefers text/markdown
26+
// Useful for LLM agents - https://www.skeptrune.com/posts/use-the-accept-header-to-serve-markdown-instead-of-html-to-llms/
27+
{
28+
source: '/:path((?!llms.txt).*)',
29+
has: [
30+
{
31+
type: 'header',
32+
key: 'accept',
33+
value: '(.*text/markdown.*)',
34+
},
35+
],
36+
destination: '/api/md/:path*',
37+
},
38+
// Explicit .md extension also serves markdown
39+
{
40+
source: '/:path*.md',
41+
destination: '/api/md/:path*',
42+
},
43+
],
44+
};
4345
},
4446
env: {},
4547
webpack: (config, {dev, isServer, ...options}) => {

0 commit comments

Comments
 (0)