Skip to content

fix: derive the dev proxy target from the nuxt dev server address#1071

Open
srcdev wants to merge 1 commit into
nuxt-modules:mainfrom
srcdev:fix/993-proxy-target
Open

fix: derive the dev proxy target from the nuxt dev server address#1071
srcdev wants to merge 1 commit into
nuxt-modules:mainfrom
srcdev:fix/993-proxy-target

Conversation

@srcdev

@srcdev srcdev commented Jun 12, 2026

Copy link
Copy Markdown

🔗 Linked issue

Refs #993 — together with #1069 this completes the fix for that issue. Carries forward the proxy-target portion of #994, as offered there; credit to @akornmeier for the original diagnosis (co-authored on the commit).

📚 Description

The Storybook→Nuxt dev asset proxy (getNuxtProxyConfig) targeted runtimeConfig.app.port ?? 3000 — that runtime-config field is virtually never set, so the proxy always pointed at hardcoded localhost:3000 and broke whenever the dev server listened anywhere else. With the startup deadlock fixed (#1069), this surfaces immediately as the EAGAIN errors on /_nuxt/* reported in #993.

Changes (deliberately only the proxy-target portion of #994, per the review feedback there — the unhead/appManifest changes are left out for separate discussion):

  • Target the dev server's actual address from nuxt.options.devServer.url (falling back to devServer.port, then localhost:3000).
  • Pass the target as a { protocol, host, port } object rather than a URL string: the dev server frequently binds the IPv6 loopback (http://[::1]:3000), and http-proxy cannot parse bracketed IPv6 hosts in string targets — it attempts to resolve the literal [::1] and fails with ENOTFOUND. This is likely why testing the original fix(storybook-addon): Issue 993 proxy errors #994 kept producing unexplained failures.
  • Exclude /_nuxt/builds/meta (app manifest) from the proxy route: those files are specific to the Storybook build and must not be answered by the Nuxt app.

Tests: new unit suite for getNuxtProxyConfig covering the URL-derived target, the bracketed-IPv6 unwrapping, both fallbacks, and the route regex (proxies /_nuxt/* and /_ipx/*, excludes /_nuxt/builds/meta/*).

Verified in combination with #1069 against the #993 reproduction (braedenfoster/storybook-test-nuxt-4): the proxy reaches the dev server with zero EAGAIN/ENOTFOUND errors logged.

(investigated and fixed with Claude Fable 5 assistance)

The Storybook->Nuxt asset proxy targeted hardcoded localhost:3000
(`runtimeConfig.app.port` is virtually never set), breaking whenever the
dev server listened elsewhere. Use nuxt.options.devServer.url instead,
passed as a protocol/host/port object because http-proxy cannot parse
bracketed IPv6 hosts (http://[::1]:3000) in string targets. Also exclude
/_nuxt/builds/meta from the proxy: app-manifest files are specific to
the Storybook build.

Based on nuxt-modules#994 by akornmeier.

Refs nuxt-modules#993

Co-Authored-By: akornmeier <akornmeier@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

👷 Deploy request for nuxt-storybook pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a26058b

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxtjs/storybook@1071
npm i https://pkg.pr.new/@storybook-vue/nuxt@1071

commit: a26058b

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.

1 participant