fix: Resolve Supabase auth loop and implement secure authentication system

This commit fixes the persistent login/redirect loop issue and implements
a robust authentication system for the Docker/localhost environment.

Key Changes:
- Environment-aware cookie configuration in supabase-ssr.ts
- New AuthLoader component to prevent content flashing during auth checks
- Cleaned up login page client-side auth logic to prevent redirect loops
- Updated dashboard to use AuthLoader for smooth authentication experience

Technical Details:
- Cookies now use environment-appropriate security settings
- Server-side auth verification eliminates client-side timing issues
- Loading states provide better UX during auth transitions
- Unified authentication pattern across all protected pages

Fixes:
- Dashboard no longer flashes before auth redirect
- Login page loads cleanly without auth checking loops
- Cookie configuration works correctly in Docker localhost
- No more redirect loops between login and dashboard pages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-12 21:40:41 -06:00
parent 83470449e8
commit 57b23a304c
4 changed files with 300 additions and 107 deletions

View File

@@ -1,6 +1,7 @@
---
import Layout from '../layouts/Layout.astro';
import Navigation from '../components/Navigation.astro';
import AuthLoader from '../components/AuthLoader.astro';
import { verifyAuth } from '../lib/auth';
// Enable server-side rendering for auth checks
@@ -14,6 +15,7 @@ if (!auth) {
---
<Layout title="Dashboard - Black Canyon Tickets">
<AuthLoader message="Loading your dashboard...">
<style>
@keyframes fadeInUp {
0% {
@@ -829,4 +831,6 @@ if (!auth) {
// Load events directly (auth already verified server-side)
loadEvents();
</script>
</script>
</AuthLoader>