fixed base URL for websockets connection
This commit is contained in:
parent
eb402e0c68
commit
bc0a2ca43c
1 changed files with 5 additions and 3 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue