Skip to content

docs(portal): say why the prerender fetch reaches the IPv4 bind - #349

Draft
mrafnadeem-apimatic wants to merge 1 commit into
devfrom
fix/portal-prerender-origin
Draft

mrafnadeem-apimatic wants to merge 1 commit into
devfrom
fix/portal-prerender-origin

Conversation

@mrafnadeem-apimatic

Copy link
Copy Markdown
Contributor

Follow-up to the review on a404e3f (preview: { host: '127.0.0.1' }, shipped in #347).

Both ends are already pinned

The review was concerned that the fetch target is still localhost and gets resolved inside TanStack Start. It isn't. @tanstack/start-plugin-core 1.171.40 (dist/esm/vite/prerender.js) starts vite.preview({ port: 0 }) and fetches every page from previewServer.resolvedUrls.local[0]. Vite 8.2.2 (resolveHostname / resolveServerUrls) builds that URL from the configured host. When the host is a literal loopback address it is used as is, with no DNS lookup. The http://localhost strings in prerender.js only parse relative page paths and never reach the network.

I ran vite.preview on this checkout:

preview.host bound address resolvedUrls.local
default ::1 http://localhost:<port>/
'127.0.0.1' 127.0.0.1 http://127.0.0.1:<port>/

So on an IPv6-only host the fetch fails the same way the bind does: it's a clean, deterministic listen error, not a mismatch that Happy Eyeballs has to rescue. TanStack Start has no option to set the prerender origin, and we don't need one.

Change

This PR changes only the comment. The old text ("binding IPv4 leaves the fetch a single address to reach") read as though the bind indirectly narrowed the fetch. The new text says why both ends match: the fetch uses the preview server's first local URL, which Vite builds from the same literal host.

The run that caught it

https://github.com/apimatic/apimatic-cli/actions/runs/35822824551, macos-latest / Node 24: Error: connect ECONNREFUSED 127.0.0.1:49193 in prerenderPages. That run used the default host, so the server was on ::1. The link is also in the commit body, so a recurrence can be checked against it.

🤖 Generated with Claude Code

TanStack Start fetches prerendered pages from the preview server's
`resolvedUrls.local[0]`, not a hard-coded `localhost`. Vite builds that
URL from the configured host, so `host: '127.0.0.1'` pins the fetch
target as well as the bind. The previous comment implied only the bind
was constrained.

Caught by https://github.com/apimatic/apimatic-cli/actions/runs/35822824551
(macos-latest / Node 24: `connect ECONNREFUSED 127.0.0.1:49193` in
prerenderPages).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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