fix: use Vercel rewrites for content negotiation (Accept: text/markdown)#27
Merged
rachaelrenk merged 1 commit intomainfrom May 6, 2026
Merged
Conversation
…leware The middlewareMode: 'edge' approach doesn't work with pre-rendered static pages — the edge function's next() forwards to /_render (the Astro server), which doesn't exist for static pages. Instead, use Vercel's built-in rewrites with header conditions in vercel.json. When an agent sends Accept: text/markdown, Vercel rewrites the request to the .md variant at the CDN level — no middleware needed. The Astro middleware in src/middleware.ts is kept for dev mode. Co-Authored-By: Oz <oz-agent@warp.dev>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
hongyi-chen
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes content negotiation for
Accept: text/markdownrequests by using Vercel's built-inrewritesinstead of Astro edge middleware.Why the previous approach failed
PR #25 added
middlewareMode: 'edge'to deploy the Astro middleware as a Vercel Edge Function. This doesn't work for pre-rendered static pages because the edge function'snext()callback forwards requests to/_render(the Astro server), which doesn't exist for static pages. The CDN just serves the cached HTML regardless.What this PR does
middlewareMode: 'edge'back to the defaultvercel()rewritesinvercel.jsonwithhasheader conditions:{ "source": "/:path+", "has": [{ "type": "header", "key": "accept", "value": ".*text/markdown.*" }], "destination": "/:path+.md" }This rewrites at the CDN level -- when an agent sends
Accept: text/markdown, Vercel serves the.mdfile directly. No middleware, no serverless function, no edge function needed.The Astro middleware in
src/middleware.tsis kept for dev mode (where it works correctly since the Astro dev server handles all requests).Expected impact
The
content-negotiationAFDocs check should flip from FAIL to PASS, bringing the score from 90 (A-) to 93+ (A).Co-Authored-By: Oz oz-agent@warp.dev