A walkthrough of implementing HTTP content negotiation on Netlify using edge functions, so that AI agents requesting `Accept: text/markdown` receive Markdown instead of HTML. The post covers the edge function configuration (filtering by method, Accept header, and URL pattern), the core logic for finding the Markdown counterpart of a blog post URL, handling inner fetch calls safely, and adjusting response headers including `Content-Type`, `Vary`, `Content-Length`, and the optional `X-Markdown-Tokens` header following Cloudflare's convention. Includes curl-based testing examples demonstrating correct behavior for various Accept header combinations.
Sort: