Skip to content

fix(vercel): prevent caching missing public assets - #4474

Open
ryoid wants to merge 1 commit into
nitrojs:mainfrom
ryoid:fix/vercel-public-asset-404-cache
Open

fix(vercel): prevent caching missing public assets#4474
ryoid wants to merge 1 commit into
nitrojs:mainfrom
ryoid:fix/vercel-public-asset-404-cache

Conversation

@ryoid

@ryoid ryoid commented Jul 23, 2026

Copy link
Copy Markdown

🔗 Linked issue

Fixes #4427

❓ 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

This adds a no-store 404 after the filesystem check so missing assets don't fall through with immutable caching.

This follows the same approach as SvelteKit.

📝 Checklist

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

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@ryoid 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 23, 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 Plus

Run ID: 813e416c-c505-46f1-9e6b-2bfbe6a064cf

📥 Commits

Reviewing files that changed from the base of the PR and between 77b77ff and 28b93f4.

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

📝 Walkthrough

Walkthrough

The Vercel preset now generates escaped public-asset route patterns, caches existing immutable assets, and returns uncached 404 responses for missing assets after filesystem handling. Tests update the route snapshot and verify the generated 404 rule.

Changes

Vercel public asset routing

Layer / File(s) Summary
Build public asset route sources
src/presets/vercel/utils.ts
generateBuildConfig filters non-fallthrough public assets and builds regex-safe route sources.
Cache and missing-asset routing
src/presets/vercel/utils.ts, test/presets/vercel.test.ts
Vercel routes cache matching assets before filesystem handling and emit uncached 404 responses for missing assets; snapshots and assertions cover the generated configuration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • nitrojs/nitro#4432: Adds immutable static file generation under the Vercel immutable namespace, related to this PR’s public asset routing.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses conventional commit format and accurately describes the Vercel caching fix.
Description check ✅ Passed The description clearly matches the PR's bug fix and explains the no-store 404 behavior.
Linked Issues check ✅ Passed The code changes implement the linked issue's requirement to stop immutable caching from reaching HTML fallbacks and return an uncached 404.
Out of Scope Changes check ✅ Passed The changes stay focused on Vercel public-asset routing and tests, with no unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@ryoid
ryoid marked this pull request as ready for review July 23, 2026 06:55
@ryoid
ryoid requested a review from pi0 as a code owner July 23, 2026 06:55
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: immutable asset cache-control leaks onto HTML fallback on asset 404s

1 participant