Skip to content

docs: clarify route-scoped middleware example path#4445

Open
BTF-Kabir-2020 wants to merge 1 commit into
nitrojs:mainfrom
BTF-Kabir-2020:docs/clarify-route-scoped-middleware-path
Open

docs: clarify route-scoped middleware example path#4445
BTF-Kabir-2020 wants to merge 1 commit into
nitrojs:mainfrom
BTF-Kabir-2020:docs/clarify-route-scoped-middleware-path

Conversation

@BTF-Kabir-2020

@BTF-Kabir-2020 BTF-Kabir-2020 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Update the route-scoped middleware handlers examples to use ./server/utils/api-auth.ts instead of ./server/middleware/api-auth.ts, and clarify that middleware/ auto-registration only happens when serverDir is set.

Fixes #4354

Why this approach

@pi0 noted on the issue / prior PRs that auto-scanning is opt-in via serverDir, so earlier wording that treated middleware/ as always-global was inaccurate.

This PR:

  • Moves the example path outside middleware/ to avoid reader confusion
  • Mentions serverDir where auto-registration is described
  • Prefers keeping route-scoped files outside middleware/ when serverDir is enabled

Notes

@BTF-Kabir-2020
BTF-Kabir-2020 requested a review from pi0 as a code owner July 17, 2026 18:07
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

@BTF-Kabir-2020 is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The routing documentation now uses a non-middleware/ handler path for route-scoped middleware and documents that global middleware auto-registration depends on serverDir.

Changes

Middleware documentation

Layer / File(s) Summary
Middleware registration guidance
docs/1.docs/5.routing.md
Updated handler examples and clarified serverDir-dependent global middleware auto-registration, route matching, and placement of route-scoped middleware files outside middleware/.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The docs changes address #4354 by fixing the route-scoped path and clarifying serverDir-based middleware registration.
Out of Scope Changes check ✅ Passed The PR only updates routing documentation and stays within the linked issue's scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title uses a conventional commit prefix and accurately summarizes the docs change about route-scoped middleware paths.
Description check ✅ Passed The description matches the documented middleware path and serverDir behavior changes in the pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4445

commit: 6840a50

Use a non-middleware handler path in the handlers examples and note that middleware auto-scan only applies when serverDir is set.

Fixes nitrojs#4354
@BTF-Kabir-2020
BTF-Kabir-2020 force-pushed the docs/clarify-route-scoped-middleware-path branch from ef88973 to 6840a50 Compare July 17, 2026 18:09
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.

docs: misleading directory path in route-scoped middleware handlers example

1 participant