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

Showing 2 changed files with 20 additions and 4 deletions.

x
0 of 2 viewed, 2 left
13 additions and 1 deletionapps/web/src/browser/browserTargetResolver.test.tsModified
View file
@@ -173,7 +173,19 @@
kind: "environment-port",
port: 5173,
}).resolvedUrl,
- ).toBe("http://[::1]:5173/");
+ ).toBe("http://localhost:5173/");
+ });
+​
+ it("maps local IPv4 environment ports onto localhost for dual-stack guests", async () => {
+ readPreparedConnection.mockReturnValue({ httpBaseUrl: "http://127.0.0.1:3773" });
+ const { resolveBrowserNavigationTarget } = await import("./browserTargetResolver");
+ expect(
+ resolveBrowserNavigationTarget(EnvironmentId.make("environment-1"), {
+ kind: "environment-port",
+ port: 5173,
+ path: "/app",
+ }).resolvedUrl,
+ ).toBe("http://localhost:5173/app");
});
​
it("leaves malformed input for the normal navigation error path", async () => {
7 additions and 3 deletionsapps/web/src/browser/browserTargetResolver.tsModified
View file
@@ -178,9 +178,13 @@
const protocol = target.protocol ?? "http";
const path = target.path?.startsWith("/") ? target.path : `/${target.path ?? ""}`;
const normalizedEnvironmentHost = environmentUrl.hostname.replace(/^\[|\]$/g, "");
- const resolvedHost = normalizedEnvironmentHost.includes(":")