Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(docs): rename proxy.ts to middleware.ts and simplify
Sushmithamallesh6dcddb83acea
diff --git a/docs/middleware.ts b/docs/middleware.tsnew file mode 100644index 000000000..956fb5ffa--- /dev/null+++ b/docs/middleware.ts@@ -0,0 +1,20 @@+import { NextRequest, NextResponse } from 'next/server';++/**+ * Serves markdown when AI agents request it via Accept: text/markdown header.+ * Test: curl -H "Accept: text/markdown" http://localhost:3000/docs/quickstart+ */+export function middleware(request: NextRequest) {+ const accept = request.headers.get('accept') || '';++ if (accept.includes('text/markdown') || accept.includes('text/plain')) {+ const mdUrl = new URL(`/llms.mdx${request.nextUrl.pathname}`, request.nextUrl.origin);+ return NextResponse.rewrite(mdUrl);+ }++ return NextResponse.next();+}++export const config = {+ matcher: ['/((?!api|_next|llms|.*\\..*).*)'],+};diff --git a/docs/proxy.ts b/docs/proxy.tsdeleted file mode 100644index 85e6744a5..000000000--- a/docs/proxy.ts+++ /dev/null@@ -1,34 +0,0 @@-import { NextRequest, NextResponse } from 'next/server';--/**- * Proxy that serves Markdown content when AI agents request it via Accept header.- * This follows Lee Robinson's "Agent-Ready" principle:- * "Serve Markdown files when Accept: text/markdown is requested"- */-export function proxy(request: NextRequest) {- const acceptHeader = request.headers.get('accept') || '';-- // Check if the request prefers markdown (AI agents)- const prefersMarkdown =- acceptHeader.includes('text/markdown') ||- acceptHeader.includes('text/plain');-- // Only apply to /docs pages (not already .md or .mdx)- const pathname = request.nextUrl.pathname;- if (- prefersMarkdown &&- pathname.startsWith('/docs') &&- !pathname.endsWith('.md') &&- !pathname.endsWith('.mdx')- ) {- // Rewrite to the markdown endpoint- const mdUrl = new URL(`${pathname}.md`, request.nextUrl.origin);- return NextResponse.rewrite(mdUrl);- }-- return NextResponse.next();-}--export const config = {- matcher: ['/docs/:path*'],-};