Skip to content

Commit 9464f91

Browse files
committed
username and password available for local mode
1 parent 68060c8 commit 9464f91

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

packages/app/src/sessions.ts

+24-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { usePrevious } from '@/utils';
1717

1818
import { getClickhouseClient } from './clickhouse';
1919
import { useSource } from './source';
20+
import { IS_LOCAL_MODE } from './config';
21+
import { getLocalConnections } from './connection';
2022

2123
export type Session = {
2224
errorCount: string;
@@ -370,6 +372,19 @@ export function useRRWebEventStream(
370372
metadata,
371373
);
372374

375+
let hostname: string | undefined;
376+
let pathname: string | undefined;
377+
let username: string | undefined;
378+
let password: string | undefined;
379+
if (IS_LOCAL_MODE) {
380+
const localConnections = getLocalConnections();
381+
const fullUrl = new URL(localConnections[0].host);
382+
hostname = fullUrl.hostname;
383+
pathname = fullUrl.pathname;
384+
username = localConnections[0].username;
385+
password = localConnections[0].password;
386+
}
387+
373388
// TODO: Change ClickhouseClient class to use this under the hood,
374389
// and refactor this to use ClickhouseClient.query
375390
const clickhouseClient = createClient({
@@ -378,14 +393,18 @@ export function useRRWebEventStream(
378393
wait_end_of_query: 0,
379394
cancel_http_readonly_queries_on_client_close: 1,
380395
},
381-
http_headers: {
382-
'x-hyperdx-connection-id': source.connection,
383-
},
384-
url: window.location.origin,
385-
pathname: '/api/clickhouse-proxy',
396+
http_headers: !IS_LOCAL_MODE
397+
? {
398+
'x-hyperdx-connection-id': source.connection,
399+
}
400+
: undefined,
401+
url: hostname ?? window.location.origin,
402+
pathname: pathname ?? '/api/clickhouse-proxy',
386403
compression: {
387404
response: true,
388405
},
406+
username,
407+
password,
389408
});
390409

391410
const fetchPromise = (async () => {

0 commit comments

Comments
 (0)