From 2657246c80a3b541c09b11006e4e37bf0ee10ab2 Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 28 Apr 2025 13:36:28 +0200 Subject: [PATCH] courrier multi account restore compose --- app/courrier/page.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index f7c39eee..45a2b69f 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -223,7 +223,12 @@ export default function CourrierPage() { if (!isMounted) return; // Call the session API to check email credentials and start prefetching - const response = await fetch('/api/courrier/session'); + const response = await fetch('/api/courrier/session', { + credentials: 'include', // Ensure cookies are sent + headers: { + 'Content-Type': 'application/json', + } + }); // Handle 401 Unauthorized with retry logic if (response.status === 401) { @@ -234,7 +239,9 @@ export default function CourrierPage() { return initSession(); } else { console.error('Max retries reached for session request'); - throw new Error('Failed to authenticate session after multiple attempts'); + // Instead of throwing, redirect to login + router.push('/courrier/login'); + return; } }