Repository navigation
fix(aeo): remove ua-based markdown serving - #47770
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughMarkdown negotiation now uses only Accept and markdown suffix inputs. Guides markdown responses add ChangesMarkdown negotiation and cache variation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify 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 `@apps/www/middleware.ts`:
- Around line 23-26: The changelog markdown rewrite still carries the .md
suffix, which can produce a doubled .md path when negotiating markdown. Update
the middleware flow in middleware.ts to strip the suffix from the changelog slug
before building the rewrite target, and pass the markdown-suffix state into
negotiateMarkdown so the decision logic can distinguish direct .md requests from
normal slugs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ac5397c2-76db-478c-9648-44990b94f498
📒 Files selected for processing (6)
apps/docs/middleware.test.tsapps/docs/middleware.tsapps/www/middleware.test.tsapps/www/middleware.tspackages/common/markdown-negotiation.test.tspackages/common/markdown-negotiation.ts
Braintrust eval report
|
The June/July marketing redesign (#47271, #47228) rebuilt the homepage and product pages off the Pages Router, silently dropping their `<link rel="alternate" type="text/markdown">` head tags, and llms-full.txt has been accidentally embedding every blog/customer/event page via an `MD_CONTENT` spread. I restored the tags behind a shared helper, added a CI drift test so a future redesign can't drop them silently again, and trimmed both llms files to the agreed docs-index shape. **Changed:** - **Markdown siblings advertised again**: homepage, the 5 product pages, pricing, and blog emit absolute `.md` alternate URLs via a new `mdAlternates(slug)` helper (the one documented consumer of the tag parses it from `<head>` and fetches the `.md` sibling, so tags must point at the sibling, never the page itself). - **Drift test**: a vitest file walks `content/md/**` and asserts every markdown-served slug's page wires the helper (or is covered by the Pages Router `_app.tsx` mechanism, whose alternate-link wiring the test also asserts directly so removing it fails CI too). Source-level assertions by design: page modules can't be imported under www's vitest config. Fails correctly when wiring is removed (verified by hiding a page and by altering the `_app.tsx` tag). - **Vector orphan fixed**: `content/md/vector.md` moved to `modules/vector` matching the live route (the page previously had no negotiation or tag, and `/modules/vector.md` 404'd); `/vector.md` now 308s to `/modules/vector.md` and the legacy `/llms/vector.txt` redirect no longer chains. - **llms.txt + llms-full.txt**: the `## Product Overview` sections are gone from both, each keeps a `## Pricing` section. This deletes the hand-maintained links array (a drift trap) and fixes the accidental ~470-page embed, shrinking llms-full.txt from ~9.8MB to ~4.9MB and dropping the 4.1MB generated content module from that route's serverless bundle. **Note:** this PR is scoped to apps/www only. The docs side (troubleshooting pages and the rest of the docs surface) is handled separately through a consolidated manifest-gated mechanism; an earlier troubleshooting-tag commit was reverted out of this branch to keep the scopes clean. <details> <summary>Why alternate tags matter (background)</summary> Agents ingest markdown far more efficiently than our rendered HTML: a fraction of the tokens and no extraction step. Since #47770 removed UA-based serving (UA sniffing broke a major AI app's fetcher and poisoned CDN caches), markdown is served only on explicit request: a `.md` suffix URL, an `Accept: text/markdown` header, or llms.txt. That's the right serving model, but it makes the markdown twin invisible to any agent that doesn't already know our URL convention, and the major AI fetchers send browser/wildcard Accept headers, so bare URLs hand them HTML. The `<link rel="alternate" type="text/markdown">` head tag is the standards-based advertisement of the sibling. It has a documented consumer today: an agent CLI that parses the tag from `<head>` and then fetches the `.md` sibling, which is also why the tag must point at a real sibling URL and never at the page itself. Peer docs sites ship this tag as table stakes. These www pages used to carry it until the June/July marketing redesign silently dropped it; the drift test in this PR turns that regression class into a CI failure. </details> ## To test Tested locally (www + docs dev servers): - [x] `/llms.txt` renders `## Documentation` + single-link `## Pricing`, no Product Overview - [x] `/llms-full.txt` renders `# Supabase` → `## Pricing` → `## Documentation`, no Product Overview, ~4.9MB - [x] Full www suite: 6 files / 71 tests green; drift test fails correctly when a page is removed or the `_app.tsx` wiring is altered - [x] `generateMdContent.mjs` emits `modules/vector`, bare `vector` slug gone On the Vercel preview (browser-verified with Playwright): - [x] Alternate tag present on `/`, `/auth`, `/database`, `/storage`, `/edge-functions`, `/realtime`, `/pricing`, and a blog post: exactly one tag each, href = preview origin + `.md` sibling - [x] `/vector.md` → 308 → `/modules/vector.md`, renders as markdown (`# Supabase Vector`) - [x] `/llms.txt` shows single-link `## Pricing`, no Product Overview - [x] Coverage sweep: all 482 `MD_PAGES` slugs + changelog index/entry curled on the preview; 471 pages carry exactly one tag, all `.md` siblings 200 as `text/markdown`. The 11 misses are legacy blog slugs whose HTML 308-redirects away (stale `MD_PAGES` entries predating this PR, no head to tag; follow-up tracked in Linear) Post-merge prod: - [ ] Full llms.txt link sweep (every linked URL 200s; previews can't cover the docs-hosted links) ## Linear - fixes GROWTH-1013 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Markdown alternate links across key product, pricing, blog, and troubleshooting pages. * Added Supabase Vector documentation covering features, use cases, workflows, and technical details. * Updated AI-focused documentation indexes with dedicated pricing content. * Added redirects for updated Vector documentation URLs. * **Tests** * Added coverage to verify Markdown documentation links stay aligned with available pages. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
The
ChatGPT-Userlive-fetch agent's user-facing reader hard-fails ((400) OK) on pages we serve it as markdown via user-agent matching, which made supabase.com blog and product pages unreadable in that assistant. I root-caused this with a controlled fetch diagnostic cross-checked against our request logs: the failing fetches never reach our origin (the failure is cached on their side), pages served as plain HTML read fine everywhere we tested, and the same failure reproduces on other major sites that serve UA-matched markdown, so the reader bug is upstream.This PR removes user-agent-based markdown serving entirely rather than special-casing one agent: UA sniffing is a guess about contractless clients whose fetchers change without notice, and this incident showed the failure mode is silent (we keep serving 200s while the user-facing agent breaks). Markdown remains available on every explicit signal —
Accept: text/markdownq-value negotiation, explicit.mdURLs, and llms.txt — which is the same contract-driven model the Claude fetcher already uses successfully (it sendsAccept: text/markdown, text/html, */*and keeps receiving markdown after this change).Changes
LLM_USER_AGENTregex and theuserAgentparameter fromnegotiateMarkdowninpackages/common/markdown-negotiation.ts; decisions now depend only onAccept, the.mdsuffix, and the markdown-variant manifestapps/www,apps/docs) to the new signature; no behavior change for Accept-negotiated or.mdrequestsVary: Acceptheader to docs guides-md 200 responses (the wwwapi-v2/mdroute already declares it).mdURLs rewrote to a doubled.md.mdpath (404) under a markdown-preferringAccept, and 406'd on a non-matchingAccept. The www middleware now strips the.mdsuffix before slug lookup and passesisMarkdownSuffixintonegotiateMarkdown, folding the separateMD_PAGES.mdblock into the single negotiation path (same shape as the docs middleware).mdnegotiation coverageTesting
Tested locally:
Verified on the Vercel previews (www + docs) with curl:
ChatGPT-UserandClaude-UserUA GETs on blog/pricing/guide pages returntext/htmlwith a default Accepttext/markdown, text/html, */*) still returnstext/markdown;Accept: text/markdownand.mdURLs returntext/markdown; probe Accept returns 406/changelog/<slug>.mdwithAccept: text/markdownreturns the entry markdown as a direct 200 (production today detours through a 308 to the bare URL); changelog index.mdand bare-entry Accept negotiation also verifiedVary: AcceptThe intermediate commit (ChatGPT-User-only exclusion) was already verified on the preview:
ChatGPT-Usergot HTML whileAccept/.md/other-UA markdown was unaffected.Expected effects post-merge: UA-driven markdown volume in the request logs (~92% of md traffic) collapses to the Accept +
.mdbaseline; named-agent page requests return to prerendered/static serving, reversing the extra Vercel function invocations the UA rewrite introduced; user-facing readability in the affected assistant recovers within ~24h as its fetch cache revalidates. The md-share dashboard gets a dated annotation; the ratio is not comparable across this change.Linear
Summary by CodeRabbit
Acceptheader and.mdlinks, making content negotiation more predictable.406 Not Acceptable, even for bot-like user agents.Accept-based cache variation header to improve correct caching behavior.