diff --git a/dashboard/src/entrypoint/main.ts b/dashboard/src/entrypoint/main.ts index faaa7982..df6c6593 100644 --- a/dashboard/src/entrypoint/main.ts +++ b/dashboard/src/entrypoint/main.ts @@ -6,20 +6,26 @@ async function main() { let url = ""; // Detect if we're running in the (production) webserver included in the matter server or not. - const isProductionServer = location.href.includes(":5580") || location.href.includes("hassio_ingress") || location.href.includes("/api/ingress/"); + const isProductionServer = location.origin.includes(":5580") || location.href.includes("hassio_ingress") || location.href.includes("/api/ingress/"); if (!isProductionServer) { // development server, ask for url to matter server let storageUrl = localStorage.getItem("matterURL"); if (!storageUrl) { + const urlParams = new URLSearchParams(window.location.search); + const suggestedUrl = urlParams.get('url'); storageUrl = prompt( "Enter Websocket URL to a running Matter Server", - "ws://localhost:5580/ws" + suggestedUrl || "ws://localhost:5580/ws" ); if (!storageUrl) { alert("Unable to connect without URL"); return; } + if (suggestedUrl) { + // Remove suggested url from address without redirecting + history.pushState({}, "", window.location.pathname); + } localStorage.setItem("matterURL", storageUrl); } url = storageUrl;