fix: derive the dev proxy target from the nuxt dev server address#1071
Open
srcdev wants to merge 1 commit into
Open
fix: derive the dev proxy target from the nuxt dev server address#1071srcdev wants to merge 1 commit into
srcdev wants to merge 1 commit into
Conversation
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>
👷 Deploy request for nuxt-storybook pending review.Visit the deploys page to approve it
|
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 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) targetedruntimeConfig.app.port ?? 3000— that runtime-config field is virtually never set, so the proxy always pointed at hardcodedlocalhost:3000and broke whenever the dev server listened anywhere else. With the startup deadlock fixed (#1069), this surfaces immediately as theEAGAINerrors 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):
nuxt.options.devServer.url(falling back todevServer.port, thenlocalhost:3000).{ protocol, host, port }object rather than a URL string: the dev server frequently binds the IPv6 loopback (http://[::1]:3000), andhttp-proxycannot parse bracketed IPv6 hosts in string targets — it attempts to resolve the literal[::1]and fails withENOTFOUND. This is likely why testing the original fix(storybook-addon): Issue 993 proxy errors #994 kept producing unexplained failures./_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
getNuxtProxyConfigcovering 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/ENOTFOUNDerrors logged.(investigated and fixed with Claude Fable 5 assistance)