-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmiddleware.js
More file actions
34 lines (26 loc) 路 1.12 KB
/
Copy pathmiddleware.js
File metadata and controls
34 lines (26 loc) 路 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { NextResponse } from 'next/server.js';
const HOMEPAGE_MARKDOWN = `# DevGlobe
DevGlobe is a global developer discovery network for humans and AI agents.
## Agent access
- MCP endpoint: https://www.devglobe.dev/mcp
- MCP documentation: https://www.devglobe.dev/docs/mcp-server
- API catalog: https://www.devglobe.dev/.well-known/api-catalog
- OpenAPI description: https://www.devglobe.dev/openapi.json
- Full agent guide: https://www.devglobe.dev/llms.txt
Use the MCP tools to search public developer profiles, inspect a profile, and request consent-gated introductions. Private contact details are never returned.
`;
export function middleware(request) {
if (request.headers.get('accept')?.toLowerCase().includes('text/markdown')) {
const tokenCount = Math.ceil(HOMEPAGE_MARKDOWN.length / 4);
return new Response(HOMEPAGE_MARKDOWN, {
headers: {
'Content-Type': 'text/markdown; charset=utf-8',
'Cache-Control': 'public, max-age=300',
'Vary': 'Accept',
'x-markdown-tokens': String(tokenCount),
},
});
}
return NextResponse.next();
}
export const config = { matcher: '/' };