Enhance authentication and debugging experience by adding detailed logging for cookie checks, session management, and user redirection. Update middleware to log authentication cookie status and user login state. Refactor login and debug pages to use hard redirects for improved reliability and include session data display. Implement custom cookie handling in Supabase client for better session management.

This commit is contained in:
2025-04-23 17:50:14 +08:00
parent 1b4e0bafc7
commit ebb1e77ecc
8 changed files with 209 additions and 29 deletions

View File

@@ -94,10 +94,19 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
return { error };
}
// 登录成功,设置会话和用户信息
console.log('登录成功,用户信息:', data.user?.email);
setSession(data.session);
setUser(data.user);
router.push('/analytics');
// 使用硬重定向代替router.push确保页面完全刷新
console.log('准备重定向到分析页面');
// 添加短暂延时确保状态已更新,然后重定向
setTimeout(() => {
window.location.href = '/analytics';
}, 100);
return {};
} catch (error) {
console.error('登录过程出错:', error);