Skip to content

feat: add support for redirecting to md if accept text/markdown#2160

Merged
atinux merged 10 commits intomainfrom
feat/docs-ai
Jan 14, 2026
Merged

feat: add support for redirecting to md if accept text/markdown#2160
atinux merged 10 commits intomainfrom
feat/docs-ai

Conversation

@atinux
Copy link
Copy Markdown
Member

@atinux atinux commented Jan 14, 2026

So AI crawler can directly access Markdown content for our docs

  • need to check if this works

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Jan 14, 2026

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

Project Deployment Review Updated (UTC)
nuxt Ready Ready Preview, Comment Jan 14, 2026 4:09pm

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Jan 14, 2026

Deployment failed with the following error:

Rewrite at index 0 has invalid `source` pattern "/docs/*".

Learn More: https://vercel.link/invalid-route-source-pattern

atinux and others added 3 commits January 14, 2026 11:17
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

The route parameter is accessed with an incorrect key name. The parameter should be slug (from the [...slug] dynamic segment), not slug.md.

View Details
📝 Patch Details
diff --git a/server/routes/raw/[...slug].md.get.ts b/server/routes/raw/[...slug].md.get.ts
index 285d4564..2cd7be80 100644
--- a/server/routes/raw/[...slug].md.get.ts
+++ b/server/routes/raw/[...slug].md.get.ts
@@ -3,7 +3,7 @@ import { stringify } from 'minimark/stringify'
 import { withLeadingSlash } from 'ufo'
 
 export default eventHandler(async (event) => {
-  const slug = getRouterParams(event)['slug.md']
+  const slug = getRouterParams(event)['slug']
   if (!slug?.endsWith('.md')) {
     throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
   }

Analysis

Incorrect route parameter key in raw markdown route handler

What fails: Line 6 of server/routes/raw/[...slug].md.get.ts accesses getRouterParams(event)['slug.md'], which returns undefined for all requests, causing every request to /raw/...md to fail with a 404 error.

How to reproduce: Make any GET request to a markdown route:

curl http://localhost:3000/raw/docs/guide.md

Result: Returns 404 "Page not found" because slug parameter is undefined, causing the check !slug?.endsWith('.md') to evaluate to true.

Expected: The request should succeed and return the markdown file content, with the slug parameter properly populated.

Root cause: In Nuxt/Nitro server routes with dynamic segments, the parameter name comes ONLY from the content inside brackets. For a filename [...slug].md.get.ts:

  • The [...slug] creates a parameter named slug
  • The .md extension and .get HTTP method suffix are NOT part of the parameter name
  • This is confirmed by the similar file server/api/v1/teams/[slug].get.ts which uses getRouterParam(event, 'slug') - not getRouterParam(event, 'slug.get')

Nitro routing documentation confirms: "You can append the HTTP method to the filename to force the route to be matched only for a specific HTTP request method... the param will be available in the event.context.params object using the bracket notation name only."

Fix: Change line 6 from const slug = getRouterParams(event)['slug.md'] to const slug = getRouterParams(event)['slug']

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