fix(dev): bind Studio, Preview, and demo-site to IPv4 loopback - #100
Merged
Conversation
Without an explicit `server.host`, Vite defaulted to IPv6-loopback-only (`::1`) on at least one contributor's Windows setup, while the trusted local runtime's origin allowlist and bootstrap flow are hardcoded to `127.0.0.1` (packages/local-runtime/src/cli.ts, docs/PHASE3_RUNTIME.md). That mismatch produced two symptoms: browsers whose localhost resolution or network path favored IPv4 couldn't reach a dev server the terminal reported as running, and a real runtime session would reject Studio's origin even once connected. Setting `host: '127.0.0.1'` explicitly on all three dev servers matches what the runtime already expects and removes the platform-dependent IPv6-vs-IPv4 guesswork. Verified: before the fix, `http://127.0.0.1:PORT` was refused while `http://[::1]:PORT` succeeded; after, Vite binds and serves on 127.0.0.1 directly. Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
frontend/vite.config.ts had no server config at all, so it defaulted to Vite's standard port 5173 -- the same port Studio uses -- and to IPv6-loopback-only binding. Once frontend joined the workspace dev fleet, `pnpm dev` started both on port 5173 simultaneously: Studio on 127.0.0.1 (this branch's earlier fix) and frontend on ::1. Since a browser's default localhost resolution tries IPv6 first, this made frontend win the race and silently serve at localhost:5173 instead of Studio, with no error from either side. Gives frontend an explicit 127.0.0.1:5176 with strictPort, matching the other three dev servers, so a real collision now fails loudly instead of one server silently masking another. Updates SETUP.md's port table and override examples. Verified: `vite` in frontend/ now reports "Local: http://127.0.0.1:5176/". Co-Authored-By: Claude <noreply@anthropic.com>
7shep
added a commit
that referenced
this pull request
Aug 3, 2026
Mirrors PR #100 and PR #101 onto this branch for local testing: - Studio, Preview, and demo-site now bind server.host to 127.0.0.1 instead of defaulting to IPv6-loopback-only, matching what the trusted local runtime's origin allowlist already expects. - apps/studio/public/dev-runtime.local.js and apps/preview/public/dev-runtime.local.js let window.__UNIVERSAL_RUNTIME__ be set before app code runs, so a real local runtime can be connected for manual testing instead of always falling back to the fixture client. Co-Authored-By: Claude <noreply@anthropic.com>
7shep
added a commit
that referenced
this pull request
Aug 3, 2026
frontend/vite.config.ts had no server config, defaulting to port 5173 (colliding with Studio) and IPv6-loopback-only binding. Since a browser's localhost resolution tries IPv6 first, frontend silently won that race over Studio's IPv4 binding, serving the marketing site at localhost:5173 instead of Studio with no error from either side. Mirrors PR #100's follow-up commit: explicit 127.0.0.1:5176 with strictPort, and updates SETUP.md's port table and override examples. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Found while debugging "terminal says the dev server is up, but the browser can't connect to localhost:5173."
Root cause
None of the three dev-server
vite.config.tsfiles setserver.host. Without it, Vite bound only IPv6 loopback (::1) on this environment. Meanwhile the trusted local runtime hardcodes127.0.0.1for its origin allowlist and bootstrap flow (packages/local-runtime/src/cli.ts:10-11,docs/PHASE3_RUNTIME.md: "binds an ephemeral port on 127.0.0.1 only"). That mismatch causes two separate symptoms:localhostresolution or network path favors IPv4 (VPNs, some proxy setups, certain Windows IPv6 configs) gets connection-refused against a server that genuinely started successfully.[::1], a real trusted-runtime session would reject Studio's origin, since the runtime only allowlistshttp://127.0.0.1:5173.Verification
Directly tested before/after on the affected machine:
http://127.0.0.1:PORT/http://[::1]:PORT/Get-NetTCPConnectionconfirmed the socket moves from::1to127.0.0.1listen after the change.pnpm --filter @universal/studio typecheck,@universal/preview typecheck,@universal/demo-site typecheck, andprettier --checkon the three files are clean.Change
Adds
host: '127.0.0.1'toserverinapps/studio/vite.config.ts,apps/preview/vite.config.ts, andexamples/demo-site/vite.config.ts. No behavior change for contributors whose Vite already happened to bind IPv4/dual-stack.Co-Authored-By: Claude noreply@anthropic.com