From 86790222ef1791c654ed44922112cb85c0cc59a7 Mon Sep 17 00:00:00 2001 From: William D'Andrea <71140800+william-dandrea@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:03:32 +0000 Subject: [PATCH] Add dynamic prefix path detection for client initialization - Extract prefix path from the current window location. - Append the detected prefix path to the base endpoint for client initialization. --- src/utils/Types.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/Types.ts b/src/utils/Types.ts index aa95266..ba03bf7 100644 --- a/src/utils/Types.ts +++ b/src/utils/Types.ts @@ -11,10 +11,10 @@ export type Connection = { export const baseEndpoint = `${window.location.protocol}//${window.location.host}`; export const endpoint = `${baseEndpoint}${window.location.pathname.replace(/\/+$/, '')}`; -export const client = new Client(baseEndpoint); +const prefixPathMatch = window.location.pathname.match(/\/([^/]+)\/playground/); +const prefixPath = prefixPathMatch ? `/${prefixPathMatch[1]}` : ''; -// export const endpoint = "http://localhost:2567/playground"; -// export const client = new Client("http://localhost:2567"); +export const client = new Client(baseEndpoint + prefixPath); export const global = { connections: [] as Connection[], };