Skip to content

feat: add markdown content-type support for message pages#791

Merged
RhysSullivan merged 1 commit into
newfrom
feat/markdown-message-pages
Dec 14, 2025
Merged

feat: add markdown content-type support for message pages#791
RhysSullivan merged 1 commit into
newfrom
feat/markdown-message-pages

Conversation

@RhysSullivan
Copy link
Copy Markdown
Collaborator

Summary

  • Add markdown response support for message pages (/m/:id) to better serve AI agents and tools that prefer consuming content in plain text/markdown
  • Support two access methods: direct URL (/m/:id.md) and Accept header detection (text/markdown or text/plain)

Changes

  • proxy.ts: Detect .md extension or markdown/plain Accept headers and rewrite to markdown route
  • message-markdown.ts: Shared utility for converting message data to markdown format
  • markdown/route.ts: Route handlers for both main-site and tenant pages with pagination support

Output Format

# Thread Title

**Server:** Server Name | **Channel:** #channel-name | **Posted:** Jan 1, 2024

---

## Question

[Message content with ![](image) attachments]

---

## Solution ✓

[Solution if marked]

---

## Replies

**@username** - Jan 1, 2024

[Reply content]

---

[Load more of the conversation](/m/123.md?cursor=...)

- 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
@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
answer-overflow-main-site Error Error Dec 14, 2025 2:38am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
answer-overflow Ignored Ignored Dec 14, 2025 2:38am
answer-overflow-dashboard Ignored Ignored Dec 14, 2025 2:38am

@RhysSullivan RhysSullivan merged commit fec5976 into new Dec 14, 2025
5 of 6 checks passed
@RhysSullivan RhysSullivan deleted the feat/markdown-message-pages branch December 14, 2025 02:39
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

? `/m/${canonicalId}.md?cursor=${cursorParam}`
: `/m/${canonicalId}.md`;
redirect(redirectUrl);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

const prefersMarkdown =
acceptHeader.includes("text/markdown") ||
acceptHeader.includes("text/plain");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant