Skip to content

Commit ca66259

Browse files
Fix playground to use browser hostname instead of localhost
When listener.hostname is not set, use window.location.hostname instead of defaulting to "localhost". Also handle standard ports (443/80) by omitting port from URL. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3543d9c commit ca66259

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

ui/src/app/playground/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,15 @@ export default function PlaygroundPage() {
247247
if (listener.routes) {
248248
listener.routes.forEach((route: Route, routeIndex: number) => {
249249
const protocol = listener.protocol === ListenerProtocol.HTTPS ? "https" : "http";
250-
const hostname = listener.hostname || "localhost";
250+
// Use listener hostname if set, otherwise use current browser location for deployed environments
251+
const hostname = listener.hostname || (typeof window !== "undefined" ? window.location.hostname : "localhost");
251252
const port = bind.port; // Use the actual port from the bind configuration
252-
const baseEndpoint = `${protocol}://${hostname}:${port}`;
253+
// For standard HTTPS (443) or HTTP (80) ports, omit the port from URL
254+
const isStandardPort = (protocol === "https" && (typeof window !== "undefined" && window.location.port === "")) ||
255+
(protocol === "http" && port === 80) ||
256+
(protocol === "https" && port === 443);
257+
const portSuffix = isStandardPort ? "" : `:${port}`;
258+
const baseEndpoint = `${protocol}://${hostname}${portSuffix}`;
253259

254260
// Generate route path and description with better pattern recognition
255261
let routePath = "/";

0 commit comments

Comments
 (0)