Skip to content

Conversation

@kricsleo
Copy link
Member

@kricsleo kricsleo commented Feb 1, 2026

πŸ”— Linked issue

resolves #3990

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Removed overly broad extension check that broke routes like /api/foo.get. Added 404 fallback to Vite instead.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@kricsleo kricsleo requested a review from pi0 as a code owner February 1, 2026 12:22
@vercel
Copy link

vercel bot commented Feb 1, 2026

@kricsleo is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

πŸ“ Walkthrough

Walkthrough

Modified the Vite dev middleware to add a 404 fallback mechanism that delegates unhandled requests to the next middleware (allowing Vite to process them) and removed extension-based filtering that previously blocked extension-less URLs from reaching the Nitro/dev pipeline.

Changes

Cohort / File(s) Summary
Vite Dev Middleware
src/build/vite/dev.ts
Added 404 fallback logic that resets nodeReq._nitroHandled and delegates to next middleware; removed extension-based request filtering in both pre-middleware and main middleware paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed The title follows conventional commits format with type 'fix' and clearly describes the main change of removing an extension check to support dotted API routes.
Description check βœ… Passed The description is related to the changeset, explaining the removal of the extension check and the 404 fallback mechanism to address dotted API route issues.
Linked Issues check βœ… Passed The PR addresses the core objective from issue #3990: removing the extension check that incorrectly treats dotted API routes as static assets, enabling proper routing for nested tRPC procedures.
Out of Scope Changes check βœ… Passed All changes in src/build/vite/dev.ts are directly related to fixing the dotted API route issue by removing the extension check and adding 404 fallback to Vite.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

πŸ€– Fix all issues with AI agents
In `@src/build/vite/dev.ts`:
- Around line 225-229: The handler that checks envRes.status === 404 should not
reset nodeReq._nitroHandled because that lets the request be processed again by
nitroDevMiddleware; instead, remove the line that sets nodeReq._nitroHandled =
false and simply call next() so Vite can handle the fallback while leaving the
Nitro-handled flag intact (change the branch in the envRes.status === 404 block
that references nodeReq._nitroHandled and next()).

Comment on lines +225 to +229
if (envRes.status === 404) {
// Allow Vite to try
nodeReq._nitroHandled = false;
return next();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor

Avoid re-running Nitro middleware after 404 fallback.

Resetting nodeReq._nitroHandled allows the same request to hit the later nitroDevMiddleware (registered at the end), duplicating Nitro dispatch for 404s. Keeping the flag set still lets Vite handle via next().

πŸ”§ Suggested change
       if (envRes.status === 404) {
         // Allow Vite to try
-        nodeReq._nitroHandled = false;
         return next();
       }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (envRes.status === 404) {
// Allow Vite to try
nodeReq._nitroHandled = false;
return next();
}
if (envRes.status === 404) {
// Allow Vite to try
return next();
}
πŸ€– Prompt for AI Agents
In `@src/build/vite/dev.ts` around lines 225 - 229, The handler that checks
envRes.status === 404 should not reset nodeReq._nitroHandled because that lets
the request be processed again by nitroDevMiddleware; instead, remove the line
that sets nodeReq._nitroHandled = false and simply call next() so Vite can
handle the fallback while leaving the Nitro-handled flag intact (change the
branch in the envRes.status === 404 block that references nodeReq._nitroHandled
and next()).

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@3994

commit: 31c89bf

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.

infinite redirect with baseUrl + nested tRPC procedure

1 participant