rewrite WS url more robustly (#2927)

This commit is contained in:
Jonathan Dobson
2025-07-10 17:48:01 -04:00
committed by GitHub
parent b0e462a23b
commit c294f338d0
3 changed files with 18 additions and 5 deletions

View File

@@ -26,6 +26,19 @@ const lsKeys = {
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 {
apiBaseUrl,
environment,
@@ -33,4 +46,6 @@ export {
artifactApiBaseUrl,
apiPathPrefix,
lsKeys,
wssBaseUrl,
newWssBaseUrl,
};