mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-07 17:23:05 +02:00
Support relative URLs. Closes #165.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user