| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
VitePress already emits a .md twin for every page (buildEnd copies the sources into dist/) and Vercel serves them as text/markdown, but the `Accept: text/markdown` negotiation never actually worked: vercel.json `rewrites` run *after* the filesystem, so the rewrite to `.md` was always shadowed by the existing `.html` file and never fired. Add Routing/Edge Middleware, which runs *before* the filesystem, to transparently rewrite page requests carrying `Accept: text/markdown` to their `.md` twin at the same URL. HTML stays the default for browsers, and Vercel's CDN already keys on the Accept header so the two variants cache separately (no Vary needed). - add middleware.ts (matcher skips assets/fonts/extensioned paths; root -> index.md) - add @vercel/functions dependency for the rewrite/next helpers - remove the dead `rewrites` block from vercel.json - update now-stale comments in .vitepress/config.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sorry, something went wrong.
|
Warning Review limit reached@sriramveeraghanta, we couldn't start this review because you've reached your PR review rate limit. More reviews will be available in 47 minutes and 37 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR. To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 7426f766-f66a-4386-853a-cebc544a236f 📥 CommitsReviewing files that changed from the base of the PR and between 2548b54 and 2a111af. 📒 Files selected for processing (1)
WalkthroughMarkdown content negotiation is migrated from a vercel.json rewrites rule to a new middleware.ts file. The middleware inspects the Accept header for text/markdown and rewrites the request path to the corresponding .md file; otherwise it passes through. The @vercel/functions package is added, the old vercel.json rewrites block is removed, and inline comments in config.ts are updated to reflect the new architecture. ChangesMarkdown Content Negotiation via Middleware
Sequence Diagram(s)sequenceDiagram
participant Agent as Agent/Client
participant Middleware as middleware.ts
participant Edge as Vercel Edge
participant Static as dist/*.md
Agent->>Middleware: GET /docs/page (Accept: text/markdown)
Middleware->>Middleware: Strip trailing slash → /docs/page.md
Middleware->>Edge: rewrite(/docs/page.md)
Edge->>Static: Fetch static .md file
Static-->>Agent: 200 text/markdown
Agent->>Middleware: GET /docs/page (Accept: text/html)
Middleware->>Edge: next() — no rewrite
Edge-->>Agent: 200 text/html
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem🚥 Pre-merge checks | ✅ 4 | ❌ 1 ❌ Failed checks (1 warning)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches 🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@middleware.ts`: - Around line 27-30: The Accept header negotiation at line 28 uses a simple substring check with includes() that doesn't properly handle case variants, quality values (q-values), or proper media range parsing. Replace the substring check with proper media type parsing logic that parses the Accept header into individual media ranges with their quality values, checks if text/markdown is present and not explicitly unacceptable (where q=0 means reject), and performs case-insensitive matching. This ensures the Accept negotiation follows HTTP content negotiation standards and correctly handles cases like "text/markdown;q=0" which should be treated as unacceptable.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 78da4a5d-67f9-4786-b725-672adefa483d
📥 CommitsReviewing files that changed from the base of the PR and between 389a8aa and 2548b54.
⛔ Files ignored due to path filters (1)
Sorry, something went wrong.
Replace the includes("text/markdown") substring check with a small parser
that handles q-values (q=0 = reject), matches the media type
case-insensitively, and ignores wildcards (*/*, text/*) so browsers keep
getting HTML.
| Back | FazBrowse Home | New Git URL |
Goal
Return a markdown representation of a page when an agent sends Accept: text/markdown, while HTML stays the default for browsers — Cloudflare's "Markdown for Agents" pattern, implemented Vercel-natively (docs.plane.so is on Vercel, not Cloudflare-proxied).
What was actually broken
The repo was already 95% there — buildEnd() copies a .md twin of every page into dist/, and Vercel serves those with Content-Type: text/markdown (verified live). But the Accept: text/markdown negotiation never fired:
The fix has to run before the filesystem. The only Vercel mechanisms that do are redirects and Routing/Edge Middleware — middleware was chosen for transparent same-URL negotiation.
Changes
Cache safety: Vercel's CDN already includes the Accept header in its cache key by default, so the HTML and markdown variants of a URL cache as separate entries — no Vary needed, no risk of agents' markdown being served to browsers.
Verified locally
Needs deploy to confirm
Middleware doesn't run under vitepress preview, so end-to-end behavior must be checked on a Vercel preview/prod deploy:
Tradeoff
The middleware runs as a small fluid-compute function on every page request (before the cache), returning next() instantly for browsers. That's the cost of transparent same-URL negotiation vs. a pure-static redirect.
Summary by CodeRabbit