Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 14:30 UTC
fix(docs): rename proxy.ts to middleware.ts and simplify
- Renamed proxy.ts → middleware.ts (Next.js requires this name) - Renamed function proxy → middleware (Next.js requires this name) - Simplified matcher to work for all pages (excludes api, _next, llms, static files) - Middleware now properly executes for content negotiation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sushmithamallesh committed
Jan 19, 2026 at 15:55 UTC
6dcddb83acea4840f2c4ff76768700171a76346e
2 files changed
+20
-34
docs/middleware.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { NextRequest, NextResponse } from 'next/server';
2
+
3
+/**
4
+ * Serves markdown when AI agents request it via Accept: text/markdown header.
5
+ * Test: curl -H "Accept: text/markdown" http://localhost:3000/docs/quickstart
6
+ */
7
+export function middleware(request: NextRequest) {
8
+ const accept = request.headers.get('accept') || '';
9
+
10
+ if (accept.includes('text/markdown') || accept.includes('text/plain')) {
11
+ const mdUrl = new URL(`/llms.mdx${request.nextUrl.pathname}`, request.nextUrl.origin);
12
+ return NextResponse.rewrite(mdUrl);
13
+ }
14
+
15
+ return NextResponse.next();
16
+}
17
+
18
+export const config = {
19
+ matcher: ['/((?!api|_next|llms|.*\\..*).*)'],
20
+};
docs/proxy.ts
deleted
-34
@@ -1,34 +0,0 @@
1
-import { NextRequest, NextResponse } from 'next/server';
2
-
3
-/**
4
- * Proxy that serves Markdown content when AI agents request it via Accept header.
5
- * This follows Lee Robinson's "Agent-Ready" principle:
6
- * "Serve Markdown files when Accept: text/markdown is requested"
7
- */
8
-export function proxy(request: NextRequest) {
9
- const acceptHeader = request.headers.get('accept') || '';
10
-
11
- // Check if the request prefers markdown (AI agents)
12
- const prefersMarkdown =
13
- acceptHeader.includes('text/markdown') ||
14
- acceptHeader.includes('text/plain');
15
-
16
- // Only apply to /docs pages (not already .md or .mdx)
17
- const pathname = request.nextUrl.pathname;
18
- if (
19
- prefersMarkdown &&
20
- pathname.startsWith('/docs') &&
21
- !pathname.endsWith('.md') &&
22
- !pathname.endsWith('.mdx')
23
- ) {
24
- // Rewrite to the markdown endpoint
25
- const mdUrl = new URL(`${pathname}.md`, request.nextUrl.origin);
26
- return NextResponse.rewrite(mdUrl);
27
- }
28
-
29
- return NextResponse.next();
30
-}
31
-
32
-export const config = {
33
- matcher: ['/docs/:path*'],
34
-};