diff --git a/backend/instance_url.ts b/backend/instance_url.ts index 50e81ca..b453028 100644 --- a/backend/instance_url.ts +++ b/backend/instance_url.ts @@ -1,4 +1,5 @@ import { isWebContainer, HostURL } from "@webcontainer/env"; +import { env } from "process"; export function getInstanceUrl(port: number) { if (isWebContainer()) { @@ -6,5 +7,9 @@ export function getInstanceUrl(port: number) { // This is why we need to convert it here. return HostURL.parse(`https://localhost:${port}`).href; } + if (env["CODESPACE_NAME"]) { + return `${env["CODESPACE_NAME"]}-${port}.app.github.dev`; + } + return `http://localhost:${port}`; } diff --git a/sim/webxdc.ts b/sim/webxdc.ts index a8d8b02..55678fb 100644 --- a/sim/webxdc.ts +++ b/sim/webxdc.ts @@ -97,6 +97,11 @@ export class DevServerTransport implements Transport { /--(\d+)--/.exec(document.location.href)?.[1] || "error in webxdc simulator" ); + } else if (location.host.endsWith(".app.github.dev")) { + return ( + /-(\d+)\.app\.github\.dev/.exec(document.location.href)?.[1] || + "error in webxdc simulator" + ); } else { return document.location.port; }