Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): open local environment ports on localhost #7300

Mergedgb1095(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/7300/headmerged by maria-rcks View on GitHub

A Vite server bound to ::1 or 127.0.0.1 was advertised as that exact host. A dual-stack Chromium guest often failed to load the other stack.

Environment-port URLs now resolve to localhost so the guest can reach either bind.

Split out of closed #7127.

Tests: vp test run apps/web/src/browser/browserTargetResolver.test.ts

Implemented with Grok 4.6 through Grok CLI.


Note

Low Risk Small, localized change to preview URL resolution for local dev; no auth or data-path impact.

Overview Environment-port preview URLs for loopback-backed environments (127.0.0.1, ::1, etc.) now resolve to http://localhost:<port>/... instead of keeping the literal loopback host in resolvedUrl.

In resolveEnvironmentPortTarget, loopback detection via isLocalLoopbackHost drives that host rewrite so Chromium’s dual-stack resolution can reach dev servers bound only on ::1 or 127.0.0.1. Remote private hosts (e.g. Tailscale/LAN) are unchanged.

Tests expect localhost for IPv6 ::1 and IPv4 127.0.0.1 environment bases, including paths.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 694d783402f8df8faf98033721ed5c1d47ae4478. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix local environment ports to resolve to localhost instead of loopback IP

In resolveEnvironmentPortTarget, when the environment host is a loopback address (e.g. 127.0.0.1 or ::1), the resolved URL now uses localhost as the host. Previously, the literal loopback address was used, which could cause issues with dual-stack environments. Behavioral Change: loopback-hosted environments that previously resolved to http://127.0.0.1:<port>/... or http://[::1]:<port>/... now resolve to http://localhost:<port>/....

Macroscope summarized 694d783.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 81e2aa92-947c-40ef-86ea-b0f5dcd80dfe

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Approved 541e423

      Straightforward bug fix that maps local loopback addresses (127.0.0.1, ::1) to 'localhost' for better Chromium dual-stack compatibility. Uses an existing utility function, limited to local development environments, and includes test coverage.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. maria-rcks merged thisa87f691

    5. maria-rcks closed this

Sign in to join this conversation.