Skip to content

feat: compat with Nitro 3#852

Draft
KazariEX wants to merge 1 commit into
nuxt:mainfrom
KazariEX:feat/nitro-v3
Draft

feat: compat with Nitro 3#852
KazariEX wants to merge 1 commit into
nuxt:mainfrom
KazariEX:feat/nitro-v3

Conversation

@KazariEX

@KazariEX KazariEX commented Jul 2, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

no response

📚 Description

Add Nitro 3 support with backward compatibility.

@KazariEX
KazariEX requested a review from danielroe as a code owner July 2, 2026 06:35
@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/fonts@852

commit: 650ca8f

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.68%. Comparing base (16e87f6) to head (650ca8f).

Files with missing lines Patch % Lines
src/assets.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #852      +/-   ##
==========================================
+ Coverage   68.01%   68.68%   +0.67%     
==========================================
  Files           9        9              
  Lines         297      297              
  Branches       67       67              
==========================================
+ Hits          202      204       +2     
+ Misses         78       76       -2     
  Partials       17       17              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change modifies font asset handling in src/assets.ts. It adds a basename import from pathe, updates the dev event handler to derive the requested font filename using basename(event.path) rather than string slicing, broadens the dev server handler route to match all nested paths under the assets base URL, and sets a conditional fallthrough option on the Nitro publicAssets configuration based on the dev mode flag.

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

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant DevServerHandler
  participant devEventHandler
  Browser->>DevServerHandler: request asset path (**)
  DevServerHandler->>devEventHandler: forward event
  devEventHandler->>devEventHandler: basename(event.path)
  devEventHandler-->>Browser: return matched font file
Loading

Related issues: None specified.

Related PRs: None specified.

Suggested labels: bug, assets

Suggested reviewers: None specified.

Poem
A rabbit hops through paths anew,
Trimming names with basename true,
Wildcards catch what once was missed,
Fallthrough set for dev's own twist,
Fonts now load where'er they roam. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Nitro 3 compatibility with backward support.
Description check ✅ Passed The description matches the changeset by stating Nitro 3 support with backward compatibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/assets.ts`:
- Around line 32-33: The font lookup in the assets handler is using event.path
directly, so query strings from h3 requests can make basename(...) miss cached
entries and cause false 404s. Update the logic in the assets.ts flow around the
filename/url lookup to derive the name from event.url.pathname, or otherwise
strip event.url.search before calling basename, so renderedFontURLs keys match
requests like font.woff2?v=1.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c03ab92c-5783-4d93-b846-93d55fbd9e50

📥 Commits

Reviewing files that changed from the base of the PR and between 16e87f6 and 650ca8f.

📒 Files selected for processing (1)
  • src/assets.ts

Comment thread src/assets.ts
Comment on lines +32 to +33
const filename = basename(event.path)
const url = context.renderedFontURLs.get(filename)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does h3's event.path getter include the query string from the request URL?

💡 Result:

Yes, the event.path getter in h3 includes the query string from the request URL [1]. In H3, event.path provides the full path of the incoming request, including both the path and the query parameters (for example, "/test?test=123") [1]. However, please note that event.path is deprecated in H3 v2 [2]. It is recommended to use event.url.pathname and event.url.search instead to access the path and query string components separately [2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant file and nearby context.
git ls-files src/assets.ts
wc -l src/assets.ts
cat -n src/assets.ts | sed -n '1,220p'

Repository: nuxt/fonts

Length of output: 6001


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check for related path handling and any existing normalization helpers.
rg -n "basename\\(|event\\.path|renderedFontURLs|assetsBaseURL|pathname|search" src

Repository: nuxt/fonts

Length of output: 874


Strip query strings before deriving the font filename. event.path includes the search string in h3, so basename(event.path) will miss cached entries for requests like font.woff2?v=1 and 404. Use event.url.pathname (or strip event.url.search) here instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/assets.ts` around lines 32 - 33, The font lookup in the assets handler is
using event.path directly, so query strings from h3 requests can make
basename(...) miss cached entries and cause false 404s. Update the logic in the
assets.ts flow around the filename/url lookup to derive the name from
event.url.pathname, or otherwise strip event.url.search before calling basename,
so renderedFontURLs keys match requests like font.woff2?v=1.

Comment thread src/assets.ts

addDevServerHandler({
route: joinURL(nuxt.options.runtimeConfig.app.baseURL || nuxt.options.app.baseURL, context.assetsBaseURL),
route: joinURL(nuxt.options.runtimeConfig.app.baseURL || nuxt.options.app.baseURL, context.assetsBaseURL, '**'),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Incompatible with Nitro 2 🧐

@KazariEX
KazariEX marked this pull request as draft July 2, 2026 06:51
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