diff --git a/frontend/src/hooks/useJobStatusWebSocket.ts b/frontend/src/hooks/useJobStatusWebSocket.ts index 24a2c8a..0eda504 100644 --- a/frontend/src/hooks/useJobStatusWebSocket.ts +++ b/frontend/src/hooks/useJobStatusWebSocket.ts @@ -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) => {