Skip to content

fix: move API markdown route to utils to prevent SSR interception#79

Merged
rsbh merged 1 commit into
mainfrom
fix/api-ssr-route
May 15, 2026
Merged

fix: move API markdown route to utils to prevent SSR interception#79
rsbh merged 1 commit into
mainfrom
fix/api-ssr-route

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented May 15, 2026

Summary

  • apis/[...slug].md.ts catch-all intercepted all /apis/** requests, returning empty 200 for non-.md paths, blocking SSR
  • Moved API markdown logic to server/utils/api-markdown.ts as an exported function
  • Root [...slug].md.ts now calls handleApiMarkdown() for /apis/ paths instead of skipping them

Test plan

  • /apis/petstore/findPetsByStatus returns full SSR HTML (was empty 200)
  • /apis/petstore/findPetsByStatus.md still returns markdown
  • /docs/getting-started SSR unaffected
  • /docs/getting-started.md markdown unaffected

🤖 Generated with Claude Code

The catch-all `apis/[...slug].md.ts` route intercepted all `/apis/**`
requests. For non-`.md` paths it returned undefined, which Nitro treated
as empty 200, blocking SSR. Moved to a util function called from the
root `[...slug].md.ts` handler instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

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

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment May 15, 2026 8:13am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d35aac16-9eec-4d4c-87ee-ac7ee16ee2d3

📥 Commits

Reviewing files that changed from the base of the PR and between df3f1e3 and cbd3d28.

📒 Files selected for processing (2)
  • packages/chronicle/src/server/routes/[...slug].md.ts
  • packages/chronicle/src/server/utils/api-markdown.ts

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Enhanced API documentation routing to efficiently handle markdown API specification requests and return appropriate responses for missing API documentation.

Walkthrough

The PR refactors API markdown handling from a Nitro request handler into a standalone function. The route handler now imports and delegates /apis/ pathname requests to handleApiMarkdown(pathname), while non-API markdown paths use the original file-based lookup logic.

Changes

API Markdown Handler Refactoring

Layer / File(s) Summary
Extract handleApiMarkdown function
packages/chronicle/src/server/utils/api-markdown.ts
The Nitro defineHandler is replaced with a standalone handleApiMarkdown(pathname: string) function that matches API specs and returns a markdown Response or throws HTTPError(404).
Integrate into markdown route handler
packages/chronicle/src/server/routes/[...slug].md.ts
The markdown route imports handleApiMarkdown and detects /apis/ paths, returning the function result with an early return instead of falling through to file-based lookup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • rohanchkrabrty
  • rohilsurana
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving API markdown route handling to utils to fix SSR interception, which is the core objective of this pull request.
Description check ✅ Passed The description clearly explains the problem (SSR interception), the solution (moving logic to utils), and provides a concrete test plan verifying the fix works correctly.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/api-ssr-route

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rsbh rsbh merged commit 08f2641 into main May 15, 2026
4 checks passed
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.

2 participants