Skip to content

fix: register server handler only for server provider - #524

Merged
antfu merged 1 commit into
nuxt:mainfrom
onmax:fix/register-server-handler-by-provider
Aug 10, 2026
Merged

fix: register server handler only for server provider#524
antfu merged 1 commit into
nuxt:mainfrom
onmax:fix/register-server-handler-by-provider

Conversation

@onmax

@onmax onmax commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

When provider is iconify, the client loads icons from the Iconify API and the server bundle resolver disables the server bundle, but the module still registers the local /api/_nuxt_icon/:collection handler. This change registers that handler only for the server provider.

StackBlitz

Link Expected
Bug nuxt-icon-non-server-handler ❌ The assertion detects the unused local handler
Fix nuxt-icon-non-server-handler-fix ✅ The production build completes without the local handler

CLI reproduction

git clone --depth 1 --filter=blob:none --sparse https://github.com/onmax/repros.git
cd repros && git sparse-checkout set nuxt-icon-non-server-handler
cd nuxt-icon-non-server-handler && pnpm i && pnpm repro

Verify fix

git sparse-checkout add nuxt-icon-non-server-handler-fix
cd ../nuxt-icon-non-server-handler-fix && pnpm i && pnpm repro

Tests

  • pnpm test:unit --run
  • pnpm lint
  • pnpm typecheck
  • pnpm build

@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/icon@524

commit: dc0f451

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The module now registers the local server API handler only when options.provider is server. A new Iconify provider fixture configures NuxtIcon with serverBundle: false. An end-to-end Vitest test builds the fixture and verifies that the local Iconify API route is not registered.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: registering the server handler only for the server provider.
Description check ✅ Passed The description directly explains the handler bug, the provider-specific fix, reproductions, and verification steps.
✨ 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.

🧹 Nitpick comments (1)
test/module.test.ts (1)

12-18: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a positive control for the server provider.

This test only checks provider: "iconify" and skips server handling. Add a separate test with provider: "server" that asserts /api/_nuxt_icon/:collection is registered, unless an existing test already covers this branch.

🤖 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 `@test/module.test.ts` around lines 12 - 18, Add a separate test alongside the
existing iconify-provider test that configures or exercises provider "server"
and asserts serverHandlers contains an entry with route
"/api/_nuxt_icon/:collection". Reuse the existing test context setup and avoid
modifying the negative assertion for the iconify provider.
🤖 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.

Nitpick comments:
In `@test/module.test.ts`:
- Around line 12-18: Add a separate test alongside the existing iconify-provider
test that configures or exercises provider "server" and asserts serverHandlers
contains an entry with route "/api/_nuxt_icon/:collection". Reuse the existing
test context setup and avoid modifying the negative assertion for the iconify
provider.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3180296d-cd3a-4ebb-87eb-97863fd935ee

📥 Commits

Reviewing files that changed from the base of the PR and between e062607 and dc0f451.

📒 Files selected for processing (3)
  • src/module.ts
  • test/fixtures/iconify-provider/nuxt.config.ts
  • test/module.test.ts

@antfu
antfu merged commit 598d438 into nuxt:main Aug 10, 2026
5 checks passed
@onmax
onmax deleted the fix/register-server-handler-by-provider branch August 10, 2026 09:04
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