fixed base URL for websockets connection

This commit is contained in:
michael 2025-10-10 12:22:26 -05:00
parent eb402e0c68
commit bc0a2ca43c

View file

@ -140,10 +140,12 @@ export function useJobStatusWebSocket(
const protocol = apiUrl.protocol === 'https:' ? 'wss:' : 'ws:';
const host = apiUrl.host; // Use backend host, not window.location.host
const basePath = `/api/v1/ws/jobs`;
const path = jobId ? `${basePath}/${jobId}` : basePath;
// Include pathname from API base URL (e.g., /video-accessibility-back)
const apiPathname = apiUrl.pathname.replace(/\/$/, ''); // Remove trailing slash
const wsPath = `/api/v1/ws/jobs`;
const fullPath = jobId ? `${apiPathname}${wsPath}/${jobId}` : `${apiPathname}${wsPath}`;
const token = encodeURIComponent(accessToken || '');
return `${protocol}//${host}${path}?token=${token}`;
return `${protocol}//${host}${fullPath}?token=${token}`;
}, [jobId, accessToken]);
const handleStatusUpdate = useCallback((update: JobStatusUpdate) => {