diff --git a/app/(admin)/migration/page.tsx b/app/(admin)/migration/page.tsx index ee0a99a..e08b98b 100644 --- a/app/(admin)/migration/page.tsx +++ b/app/(admin)/migration/page.tsx @@ -40,8 +40,24 @@ const getApiBase = (): string => { return `${backendUrl}/api/v1/migration`; }; +const getAuthToken = (): string | null => { + let token = getAccessToken(); + if (!token && typeof window !== 'undefined') { + token = + localStorage.getItem('access_token') || + localStorage.getItem('token') || + sessionStorage.getItem('access_token') || + sessionStorage.getItem('token'); + if (!token && document.cookie) { + const match = document.cookie.match(/(?:^|;\s*)(?:access_token|token|jwt)=([^;]+)/); + if (match) token = decodeURIComponent(match[1]); + } + } + return token; +}; + const authFetch = async (url: string, init?: RequestInit): Promise => { - const token = getAccessToken(); + const token = getAuthToken(); const headers = new Headers(init?.headers || {}); if (token) { headers.set('Authorization', `Bearer ${token}`); @@ -288,7 +304,7 @@ export default function MigrationPage() { // Connect SSE Live Stream if (activeId) { - const token = getAccessToken(); + const token = getAuthToken(); const sseUrl = `${apiBase}/jobs/${activeId}/stream${token ? `?token=${encodeURIComponent(token)}` : ''}`; const eventSource = new EventSource(sseUrl); eventSource.onmessage = (event) => {