Skip to content

fix(vercel): strip trailing slash from prerendered route overrides#4412

Open
thribhuvan003 wants to merge 1 commit into
nitrojs:mainfrom
thribhuvan003:fix/vercel-trailing-slash-overrides
Open

fix(vercel): strip trailing slash from prerendered route overrides#4412
thribhuvan003 wants to merge 1 commit into
nitrojs:mainfrom
thribhuvan003:fix/vercel-trailing-slash-overrides

Conversation

@thribhuvan003

Copy link
Copy Markdown
Contributor

🔗 Linked issue

resolves #4392

❓ 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

prerendering a route with a trailing slash (e.g. /slash/) emits a Build Output override whose path keeps the slash — "slash/index.html": { "path": "slash/" } — and vercel doesn't match override paths like that, so the route falls through to the server function instead of being served statically (repro + live deploy in #4392).

this strips the trailing slash the same way the leading one is already stripped, so the override becomes "path": "slash". the root route is unaffected (/ still maps to ""). extended the vercel:web preset test with a prerendered /slash/ route.

the same line exists on the v2 branch (src/presets/vercel/utils.ts:166) — happy to open a backport if useful.

📝 Checklist

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

@thribhuvan003
thribhuvan003 requested a review from pi0 as a code owner July 9, 2026 00:58
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@thribhuvan003 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 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 28a71a89-f4cc-4de5-81bb-3ba850ebcf99

📥 Commits

Reviewing files that changed from the base of the PR and between eee0abd and 44908da.

📒 Files selected for processing (3)
  • src/presets/vercel/utils.ts
  • test/presets/fixtures/slash.ts
  • test/presets/vercel.test.ts

📝 Walkthrough

Walkthrough

This change updates Vercel prerender override path normalization to remove trailing slashes and adds regression coverage for a prerendered /slash/ route, including fixture setup and snapshot expectations for generated config and functions output.

Changes

Vercel override path handling

Layer / File(s) Summary
Normalize override paths
src/presets/vercel/utils.ts
Vercel prerender override path values now strip both leading and trailing slashes when build config overrides are generated.
Cover trailing-slash prerender route
test/presets/vercel.test.ts, test/presets/fixtures/slash.ts
The Vercel preset test adds a /slash handler and prerenders /slash/, then updates snapshots to expect the normalized slash override and generated functions/slash.func entry.

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

Possibly related PRs

  • nitrojs/nitro#4124: Also changes src/presets/vercel/utils.ts build config route and override generation logic for the Vercel preset.
🚥 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 uses a conventional commit format and clearly describes the trailing-slash fix.
Description check ✅ Passed The description matches the Vercel trailing-slash override bug and the added test coverage.
Linked Issues check ✅ Passed The changes strip trailing slashes from Vercel override paths and add a regression test for /slash/.
Out of Scope Changes check ✅ Passed The fixture and snapshot updates are directly tied to the reported bug and test coverage.
✨ 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.

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.

Vercel preset emits trailing-slash override paths

1 participant