fix: deploy middleware as Vercel Edge Function for content negotiation#26
Closed
rachaelrenk wants to merge 1 commit intomainfrom
Closed
fix: deploy middleware as Vercel Edge Function for content negotiation#26rachaelrenk wants to merge 1 commit intomainfrom
rachaelrenk wants to merge 1 commit intomainfrom
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
Moved to PR #25 instead. |
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
One-line fix:
vercel()tovercel({ middlewareMode: 'edge' }).The content negotiation middleware from PR #23 wasn't working in production because pre-rendered pages are served as static files by Vercel's CDN -- the Astro middleware never runs at request time for them.
Root cause
The default
middlewareMode: 'classic'only runs middleware:Since all doc pages are pre-rendered, the
Accept: text/markdowncheck insrc/middleware.tswas only evaluated during the build, not when agents actually request pages.Fix
middlewareMode: 'edge'deploys the Astro middleware as a separate Vercel Edge Function that runs at request time for ALL requests, including static pages.Expected impact
The
content-negotiationAFDocs check should flip from FAIL to PASS, bringing the score from 88 (B+) toward 93+ (A).Co-Authored-By: Oz oz-agent@warp.dev