Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dashboard/src/entrypoint/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading