Files
obc-terrassement/app/(protected)/layout.tsx
Claude 5514af9555 fix: remove middleware and route groups to fix Vercel deployment
- Remove middleware.ts entirely (caused __dirname ReferenceError in Edge)
- Auth protection handled by dashboard layout.tsx (server-side redirect)
- Move pages out of (marketing) and (auth) route groups to fix 404 on /
- Keep (protected) route group for dashboard/formations/profil shared layout

https://claude.ai/code/session_01H2aRGDaKgarPvhay2HxN6Y
2026-02-08 14:17:09 +00:00

45 lines
1010 B
TypeScript

import { redirect } from "next/navigation";
import { createClient } from "@/lib/supabase/server";
import Sidebar from "@/components/dashboard/Sidebar";
import type { Profile } from "@/types/database.types";
export default async function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
const supabase = await createClient();
// Vérifier l'authentification
const {
data: { user },
} = await supabase.auth.getUser();
if (!user) {
redirect("/login");
}
// Récupérer le profil
const { data: profile } = await supabase
.from("profiles")
.select("*")
.eq("id", user.id)
.single() as { data: Profile | null };
if (!profile) {
redirect("/login");
}
// Vérifier l'abonnement actif
if (profile.subscription_status !== "active") {
redirect("/login");
}
return (
<div className="flex min-h-screen">
<Sidebar user={profile} />
<main className="flex-1 p-6 md:p-10 overflow-y-auto">{children}</main>
</div>
);
}