Skip to content

fix(vite): keep no-fallthrough public dir base and HEAD in sync with dev app routes - #4737

Merged
pi0 merged 1 commit into
mainfrom
fix/vite-dev-public-base
Oct 7, 2026
Merged

pi0 merged 1 commit into
mainfrom
fix/vite-dev-public-base

Conversation

@pi0x

@pi0x pi0x commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #4736 (#4735), from review findings.

  • Bare public dir base: hasRoute recorded no-fallthrough public dirs as <base>/**, which also matches /pub and /pub/. Those became a final 404 in Vite dev, while production (and dev before refactor(vite): use NitroDevApp routes to route dev requests before vite #4736) passes them on to the app, e.g. an SSR page at /docs next to a /docs public dir. Now recorded as <base>/:path+, so only paths below the dir match. Root public dirs are skipped explicitly.
  • HEAD: hasRoute now falls back from HEAD to GET, matching h3's route lookup, so it agrees with what the dev app actually serves.
  • Tests: new unit test for NitroDevApp.hasRoute (both baseURLs: methods, HEAD, proxies, middleware and root catch-all skipping, public dirs). E2E test for /pub and /pub/ page navigations under both baseURLs, and the missing-asset 404 case now also asserts the response isn't HTML. 6 of the new cases fail without the fix.
  • .agents/vite-dev.md updated for hasRoute.

🤖 Generated with AI assistant

…dev app routes

`hasRoute` no longer claims the bare base of a no-fallthrough public dir (same as production)
and falls back from HEAD to GET like h3.
@pi0x
pi0x requested a review from pi0 as a code owner October 6, 2026 15:30
@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
nitro.build Ready Ready Preview Oct 6, 2026 3:31pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee08b003-5635-43de-a276-b848cb53ff46
📥 Commits

Reviewing files that changed from the base of the PR and between d631065 and d0cbb9c.

📒 Files selected for processing (4)
  • .agents/vite-dev.md
  • src/dev/app.ts
  • test/unit/dev-app-routes.test.ts
  • test/vite/base-dev-handlers.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

NitroDevApp changes public-asset route registration and method matching. Unit tests cover handler, proxy, and asset route recognition. Vite tests cover public-asset base-path responses and missing assets. The dev-routing documentation updates route and dispatch descriptions.

Changes

Vite dev-app routing

Layer / File(s) Summary
Dev-app route registration and matching
.agents/vite-dev.md, src/dev/app.ts, test/unit/dev-app-routes.test.ts
Public-asset routes are registered only when fallthrough is disabled and the base URL is non-root. hasRoute handles case-insensitive methods and matches HEAD requests to GET routes. Unit tests cover handlers, proxies, middleware, catch-all routes, and public assets.
Public-asset response behavior
.agents/vite-dev.md, test/vite/base-dev-handlers.test.ts
Vite tests check that /pub and /pub/ return status 200 for HTML document requests and that a missing public asset does not have an HTML content type. The documentation describes 404 fallthrough unless _nitroDevRoute is set.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d0cbb

The routing changes and accompanying tests present no identified blocker; merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d0cbb

The change adjusts development-server routing without adding handlers, proxy destinations, or privileges. Reviewed paths preserve explicit-route precedence and final missing-asset responses. Remaining uncertainty concerns underlying router semantics that were not independently exercised.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Clients able to reach the development server can select methods and paths that influence request ownership. The changed exposure is confined to classification of configured development routes and public-asset bases; the compared production-code change adds no handler, proxy destination, filesystem root, credential, or privilege.

Trust Boundaries and Controls

  • inferred — No control bypass was established through the changed classifier. HEAD fallback is limited to GET classification, explicit application-route precedence remains unchanged, and non-fallthrough asset descendants retain final-response ownership rather than falling into an HTML catch-all. Directory bases intentionally return to normal page-or-asset dispatch.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits with the fix(vite): prefix and describes the route-matching changes.
Description check ✅ Passed The description explains the public-directory and HEAD route-matching changes, the related tests, and the documentation update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 Oct 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: d0cbb9c

@pi0
pi0 merged commit 2641042 into main Oct 7, 2026
15 checks passed
@pi0
pi0 deleted the fix/vite-dev-public-base branch October 7, 2026 04:49

This branch was successfully deployed

1 active deployment
Preview — d0cbb9c2 Deployed Oct 6, 2026 by vercel[bot]
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