Support relative URLs. Closes #165.

This commit is contained in:
Jack Kingsman
2026-04-05 22:11:12 -07:00
parent c2e1a3cbe6
commit 1991f2515b
15 changed files with 107 additions and 47 deletions
+3 -1
View File
@@ -54,7 +54,9 @@ export function useWebSocket(options: UseWebSocketOptions) {
const connect = useCallback(() => {
// Determine WebSocket URL based on current location
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${protocol}//${window.location.host}/api/ws`;
// Resolve relative to the page so sub-path reverse proxies work
const base = new URL('./api/ws', window.location.href);
const wsUrl = `${protocol}//${base.host}${base.pathname}`;
const ws = new WebSocket(wsUrl);