Skip to content

fix(hosting): use dynamic hostname for external link#1141

Open
tanxan wants to merge 2 commits into
firebase:masterfrom
tanxan:fix/emulator-hosting-linkToExternal
Open

fix(hosting): use dynamic hostname for external link#1141
tanxan wants to merge 2 commits into
firebase:masterfrom
tanxan:fix/emulator-hosting-linkToExternal

Conversation

@tanxan

@tanxan tanxan commented Jul 6, 2026

Copy link
Copy Markdown

Fixes #1140

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Manual: Verified in a container environment; the Hosting link now dynamically reflects the current hostname, maintaining origin consistency.
  • Automated: Ran npm test, all tests passed successfully.

The Solution

Instead of relying on the static config.hosting.hostAndPort for external navigation, this change dynamically passes window.location.hostname into the hostAndPort helper directly within the component.

// Before
linkToExternal={config.hosting && `//${config.hosting.hostAndPort}/`}

// After
linkToExternal={
  config.hosting &&
  `//${hostAndPort(window.location.hostname, config.hosting.port)}/`
}

@google-cla

google-cla Bot commented Jul 6, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the hosting emulator card link to dynamically construct the URL using the current window's hostname and the hosting port via the hostAndPort helper. Feedback was provided regarding IPv6 addresses, where window.location.hostname already contains square brackets, potentially leading to an invalid URL (e.g., //[[::1]]:5000/). It is recommended to strip any existing square brackets from the hostname before passing it to hostAndPort.

Comment thread src/components/Home/index.tsx
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@wiz-9635d3485b

wiz-9635d3485b Bot commented Jul 6, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 2 Low
Software Management Finding Software Management Findings -
Total 2 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

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.

Static 127.0.0.1 link on Hosting card breaks features relying on same origin

1 participant