Skip to content

Commit 695eb08

Browse files
rachaelrenkoz-agent
andcommitted
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 <oz-agent@warp.dev>
1 parent c20e878 commit 695eb08

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

astro.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,9 @@ export default defineConfig({
163163
}),
164164
docsMarkdownIntegration(),
165165
],
166-
adapter: vercel(),
166+
// Deploy Astro middleware as a Vercel Edge Function so it runs at
167+
// request time for ALL pages, including pre-rendered static pages.
168+
// Without this, middleware only runs at build time for static pages
169+
// and content negotiation (Accept: text/markdown) doesn't work.
170+
adapter: vercel({ middlewareMode: 'edge' }),
167171
});

0 commit comments

Comments
 (0)