From fcd6886af6fc2403d28e7cf45e2bc61154115bc8 Mon Sep 17 00:00:00 2001 From: Rachael Rose Renk <91027132+rachaelrenk@users.noreply.github.com> Date: Tue, 5 May 2026 12:57:41 -1000 Subject: [PATCH] fix: deploy middleware as Vercel Edge Function for content negotiation The Astro middleware in src/middleware.ts was not running at request time for pre-rendered (static) pages. The default middlewareMode ('classic') only executes middleware at build time for static pages, so Accept: text/markdown requests were served HTML from Vercel's CDN cache. Setting middlewareMode: 'edge' deploys the middleware as a separate Vercel Edge Function that runs at request time for ALL requests, including static pages. This enables content negotiation so agents sending Accept: text/markdown get clean markdown automatically. Co-Authored-By: Oz --- astro.config.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/astro.config.mjs b/astro.config.mjs index f330868..a50ea08 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -166,5 +166,9 @@ export default defineConfig({ }), docsMarkdownIntegration(), ], - adapter: vercel(), + // Deploy Astro middleware as a Vercel Edge Function so it runs at + // request time for ALL pages, including pre-rendered static pages. + // Without this, middleware only runs at build time for static pages + // and content negotiation (Accept: text/markdown) doesn't work. + adapter: vercel({ middlewareMode: 'edge' }), });