rewrite WS url more robustly (#2927)
This commit is contained in:
@@ -8,19 +8,15 @@ import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
|||||||
import { envCredential } from "@/util/env";
|
import { envCredential } from "@/util/env";
|
||||||
import { toast } from "@/components/ui/use-toast";
|
import { toast } from "@/components/ui/use-toast";
|
||||||
import RFB from "@novnc/novnc/lib/rfb.js";
|
import RFB from "@novnc/novnc/lib/rfb.js";
|
||||||
import { environment } from "@/util/env";
|
import { environment, wssBaseUrl, newWssBaseUrl } from "@/util/env";
|
||||||
import { cn } from "@/util/utils";
|
import { cn } from "@/util/utils";
|
||||||
import { useClientIdStore } from "@/store/useClientIdStore";
|
import { useClientIdStore } from "@/store/useClientIdStore";
|
||||||
import type {
|
import type {
|
||||||
TaskApiResponse,
|
TaskApiResponse,
|
||||||
WorkflowRunStatusApiResponse,
|
WorkflowRunStatusApiResponse,
|
||||||
} from "@/api/types";
|
} from "@/api/types";
|
||||||
|
|
||||||
import "./browser-stream.css";
|
import "./browser-stream.css";
|
||||||
|
|
||||||
const wssBaseUrl = import.meta.env.VITE_WSS_BASE_URL;
|
|
||||||
const newWssBaseUrl = wssBaseUrl.replace("/api", "");
|
|
||||||
|
|
||||||
interface CommandTakeControl {
|
interface CommandTakeControl {
|
||||||
kind: "take-control";
|
kind: "take-control";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ function BrowserSession() {
|
|||||||
try {
|
try {
|
||||||
await client.get(`/browser_sessions/${browserSessionId}`);
|
await client.get(`/browser_sessions/${browserSessionId}`);
|
||||||
setHasBrowserSession(true);
|
setHasBrowserSession(true);
|
||||||
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setHasBrowserSession(false);
|
setHasBrowserSession(false);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,6 +26,19 @@ const lsKeys = {
|
|||||||
optimisticBrowserSession: "skyvern.optimisticBrowserSession",
|
optimisticBrowserSession: "skyvern.optimisticBrowserSession",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const wssBaseUrl = import.meta.env.VITE_WSS_BASE_URL;
|
||||||
|
|
||||||
|
let newWssBaseUrl = wssBaseUrl;
|
||||||
|
try {
|
||||||
|
const url = new URL(wssBaseUrl);
|
||||||
|
if (url.pathname.startsWith("/api")) {
|
||||||
|
url.pathname = url.pathname.replace(/^\/api/, "");
|
||||||
|
}
|
||||||
|
newWssBaseUrl = url.toString();
|
||||||
|
} catch (e) {
|
||||||
|
newWssBaseUrl = wssBaseUrl.replace("/api", "");
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
apiBaseUrl,
|
apiBaseUrl,
|
||||||
environment,
|
environment,
|
||||||
@@ -33,4 +46,6 @@ export {
|
|||||||
artifactApiBaseUrl,
|
artifactApiBaseUrl,
|
||||||
apiPathPrefix,
|
apiPathPrefix,
|
||||||
lsKeys,
|
lsKeys,
|
||||||
|
wssBaseUrl,
|
||||||
|
newWssBaseUrl,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user