feat: add markdown content-type support for message pages#791
Conversation
- Add /m/:id.md URL pattern for direct markdown access - Detect text/markdown or text/plain Accept headers and serve markdown - Create shared message-markdown.ts utility for markdown generation - Support both main-site and tenant routes with pagination
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| url.pathname = `/m/${messageMatch[1]}/markdown`; | ||
| return NextResponse.rewrite(url); | ||
| } | ||
| } |
There was a problem hiding this comment.
Bug: Markdown rewrite bypasses tenant routing
The early markdown rewrites (/m/:id.md and Accept: text/*) return before the tenant/subpath logic runs, so tenant-domain requests never get rewritten to /${actualHost}/.... This can route tenant traffic to the main-site handler, bypass subpath redirects, and potentially serve the wrong server’s message content under a tenant domain.
| ? `/m/${canonicalId}.md?cursor=${cursorParam}` | ||
| : `/m/${canonicalId}.md`; | ||
| redirect(redirectUrl); | ||
| } |
There was a problem hiding this comment.
Bug: Markdown route skips custom-domain redirect
The main-site markdown handler fetches headerData and renders markdown without the custom-domain redirect behavior present on the HTML message page. For servers with server.customDomain, this can create duplicate content and serve markdown from a non-canonical host/path.
| const prefersMarkdown = | ||
| acceptHeader.includes("text/markdown") || | ||
| acceptHeader.includes("text/plain"); | ||
|
|
There was a problem hiding this comment.
Bug: Accept header matching is case-sensitive
prefersMarkdown uses acceptHeader.includes(...) without normalizing case. Since media types are case-insensitive, clients sending Text/Markdown or other casing won’t trigger the markdown rewrite, causing inconsistent behavior for Accept-based negotiation.
Summary
/m/:id) to better serve AI agents and tools that prefer consuming content in plain text/markdown/m/:id.md) and Accept header detection (text/markdownortext/plain)Changes
.mdextension or markdown/plain Accept headers and rewrite to markdown routeOutput Format