diff --git a/packages/code-studio/src/main/AppInit.tsx b/packages/code-studio/src/main/AppInit.tsx index 52547b2ed0..3edf524887 100644 --- a/packages/code-studio/src/main/AppInit.tsx +++ b/packages/code-studio/src/main/AppInit.tsx @@ -52,6 +52,7 @@ import { createCoreClient, createSessionWrapper, getAuthType, + getEnvoyPrefix, getLoginOptions, getSessionDetails, } from './SessionUtils'; @@ -170,7 +171,12 @@ function AppInit(props: AppInitProps) { navigator.userAgent ); - const coreClient = createCoreClient(); + const envoyPrefix = getEnvoyPrefix(); + const options = + envoyPrefix != null + ? { headers: { 'envoy-prefix': envoyPrefix } } + : undefined; + const coreClient = createCoreClient(options); const authType = getAuthType(); log.info(`Login using auth type ${authType}...`); const [loginOptions, sessionDetails] = await Promise.all([ diff --git a/packages/code-studio/src/main/SessionUtils.ts b/packages/code-studio/src/main/SessionUtils.ts index 77027e140b..5a544e392e 100644 --- a/packages/code-studio/src/main/SessionUtils.ts +++ b/packages/code-studio/src/main/SessionUtils.ts @@ -3,6 +3,7 @@ import { SessionWrapper, } from '@deephaven/dashboard-core-plugins'; import dh, { + ConnectOptions, CoreClient, IdeConnection, LoginOptions, @@ -42,6 +43,11 @@ export function getAuthType(): AUTH_TYPE { } } +export function getEnvoyPrefix(): string | null { + const searchParams = new URLSearchParams(window.location.search); + return searchParams.get('envoyPrefix'); +} + /** * @returns New connection to the server */ @@ -89,12 +95,12 @@ export async function createSessionWrapper( }; } -export function createCoreClient(): CoreClient { +export function createCoreClient(options?: ConnectOptions): CoreClient { const websocketUrl = getWebsocketUrl(); log.info('createCoreClient', websocketUrl); - return new dh.CoreClient(websocketUrl); + return new dh.CoreClient(websocketUrl, options); } async function requestParentLoginOptions(): Promise { diff --git a/packages/jsapi-types/src/dh.types.ts b/packages/jsapi-types/src/dh.types.ts index 9e722698da..02070d9e6d 100644 --- a/packages/jsapi-types/src/dh.types.ts +++ b/packages/jsapi-types/src/dh.types.ts @@ -1066,6 +1066,10 @@ export interface StorageService { createDirectory(path: string): Promise; } +export interface ConnectOptions { + headers?: Record; +} + export interface CoreClientContructor extends Evented { EVENT_CONNECT: string; EVENT_DISCONNECT: string; @@ -1073,7 +1077,7 @@ export interface CoreClientContructor extends Evented { EVENT_RECONNECT_AUTH_FAILED: string; EVENT_REFRESH_TOKEN_UPDATED: string; LOGIN_TYPE_ANONYMOUS: string; - new (serverUrl: string): CoreClient; + new (serverUrl: string, options?: ConnectOptions): CoreClient; } export interface CoreClient extends CoreClientContructor {