Fix vercel link scope error

This commit is contained in:
2569718930@qq.com
2026-03-17 15:23:59 +08:00
parent 5d2ed68cdf
commit 7345b70958
+13 -1
View File
@@ -677,7 +677,19 @@ export function AccountCenter() {
headers.Authorization = `Bearer ${token}`;
} catch (error) {
if (requireAuth) throw error;
// Non-authenticated page load — silently skip.
// Best-effort fallback: use current cached session token (if any)
// even when refresh failed, so same-origin API routes can still auth.
try {
const {
data: { session },
} = await getSupabaseBrowserClient().auth.getSession();
const fallbackToken = String(session?.access_token || "").trim();
if (fallbackToken) {
headers.Authorization = `Bearer ${fallbackToken}`;
}
} catch {
// Non-authenticated page load — silently skip.
}
}
return headers;
},