import {redirect} from 'next/navigation';
import {getServerSession} from '@/features/auth/services/serverSession';

/**
 * `/` normally never renders — src/proxy.ts redirects it first. This is the
 * backstop for the case where the proxy's matcher is ever narrowed, and it
 * makes the same decision from the same source of truth rather than guessing:
 * signed in → the workspace, signed out → the sign-in screen.
 *
 * Never a static redirect to /dashboard. That was the old behaviour, and it is
 * exactly how an unauthenticated visitor used to land inside the app.
 */
export default async function RootPage() {
  const session = await getServerSession();
  redirect(session ? '/dashboard' : '/login');
}
