Middleware
GeoAIMiddleware handles AI crawler detection, llms.txt serving, and optional Link header injection. Applied automatically when you import GeoAIModule.
Responsibilities
- Serves llms.txt routes (
/llms.txt,/llms-full.txt,/.well-known/llms.txt) - Detects AI bots and tracks their visits (fire-and-forget, non-blocking)
- Injects
Linkheader on all responses (wheninjectLinkHeader: true)
llms.txt routes
These routes are handled by the middleware — not the controller — for performance. They respond before the NestJS pipeline (guards, interceptors, pipes) runs:
| Route | Content |
|---|---|
GET /llms.txt | Standard llms.txt |
GET /llms-full.txt | Full version with content |
GET /.well-known/llms.txt | Well-known URI (same as /llms.txt) |
All responses include Content-Type: text/plain; charset=utf-8 and Cache-Control: public, max-age={cacheMaxAge}.
Disabling
Set registerMiddleware: false in module options if you need custom handling:
typescript
GeoAIModule.forRoot({
// ...
registerMiddleware: false,
})