diff --git a/app/(protected)/dashboard/page.tsx b/app/(protected)/dashboard/page.tsx index d8f42b6..9190b20 100644 --- a/app/(protected)/dashboard/page.tsx +++ b/app/(protected)/dashboard/page.tsx @@ -4,6 +4,8 @@ import ProgressBar from "@/components/dashboard/ProgressBar"; import ModuleCard from "@/components/dashboard/ModuleCard"; import type { Module, UserProgress, Profile } from "@/types/database.types"; +export const runtime = "nodejs"; + export default async function DashboardPage() { const supabase = await createClient(); diff --git a/app/(protected)/formations/[moduleId]/page.tsx b/app/(protected)/formations/[moduleId]/page.tsx index 6fb97d8..95f9d9a 100644 --- a/app/(protected)/formations/[moduleId]/page.tsx +++ b/app/(protected)/formations/[moduleId]/page.tsx @@ -5,6 +5,8 @@ import Card from "@/components/ui/Card"; import MarkCompleteButton from "./MarkCompleteButton"; import type { Module, UserProgress } from "@/types/database.types"; +export const runtime = "nodejs"; + interface ModulePageProps { params: Promise<{ moduleId: string }>; } diff --git a/app/(protected)/formations/page.tsx b/app/(protected)/formations/page.tsx index f9ea339..3794653 100644 --- a/app/(protected)/formations/page.tsx +++ b/app/(protected)/formations/page.tsx @@ -3,6 +3,8 @@ import ModuleCard from "@/components/dashboard/ModuleCard"; import ProgressBar from "@/components/dashboard/ProgressBar"; import type { Module, UserProgress } from "@/types/database.types"; +export const runtime = "nodejs"; + export default async function FormationsPage() { const supabase = await createClient(); diff --git a/app/(protected)/layout.tsx b/app/(protected)/layout.tsx index 21f3c8b..7041ffa 100644 --- a/app/(protected)/layout.tsx +++ b/app/(protected)/layout.tsx @@ -3,6 +3,8 @@ import { createClient } from "@/lib/supabase/server"; import Sidebar from "@/components/dashboard/Sidebar"; import type { Profile } from "@/types/database.types"; +export const runtime = "nodejs"; + export default async function DashboardLayout({ children, }: { diff --git a/app/api/candidature/route.ts b/app/api/candidature/route.ts index c72655d..c827fa1 100644 --- a/app/api/candidature/route.ts +++ b/app/api/candidature/route.ts @@ -2,6 +2,8 @@ import { NextResponse } from "next/server"; import { createAdminClient } from "@/lib/supabase/server"; import type { CandidatureInsert } from "@/types/database.types"; +export const runtime = "nodejs"; + export async function POST(request: Request) { try { const body = await request.json(); diff --git a/app/api/formations/[moduleId]/route.ts b/app/api/formations/[moduleId]/route.ts index 68f2ebf..aa606eb 100644 --- a/app/api/formations/[moduleId]/route.ts +++ b/app/api/formations/[moduleId]/route.ts @@ -2,6 +2,8 @@ import { NextResponse } from "next/server"; import { createClient } from "@/lib/supabase/server"; import type { Module, UserProgress } from "@/types/database.types"; +export const runtime = "nodejs"; + // GET /api/formations/[moduleId] - Récupérer un module export async function GET( _request: Request, diff --git a/app/api/stripe/create-checkout/route.ts b/app/api/stripe/create-checkout/route.ts index 0c3eff7..f973150 100644 --- a/app/api/stripe/create-checkout/route.ts +++ b/app/api/stripe/create-checkout/route.ts @@ -2,6 +2,8 @@ import { NextResponse } from "next/server"; import { stripe } from "@/lib/stripe/client"; import { getBaseUrl } from "@/lib/utils"; +export const runtime = "nodejs"; + export async function POST(request: Request) { try { const body = await request.json(); diff --git a/lib/supabase/server.ts b/lib/supabase/server.ts index 6f56612..0fe5634 100644 --- a/lib/supabase/server.ts +++ b/lib/supabase/server.ts @@ -1,4 +1,5 @@ import { createServerClient } from "@supabase/ssr"; +import { createClient as createSupabaseClient } from "@supabase/supabase-js"; import { cookies } from "next/headers"; import type { Database } from "@/types/database.types"; @@ -29,17 +30,10 @@ export const createClient = async () => { }; // Client admin avec service role (webhooks, opérations admin) +// Utilise @supabase/supabase-js directement (pas besoin de cookies) export const createAdminClient = () => { - return createServerClient( + return createSupabaseClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, - process.env.SUPABASE_SERVICE_ROLE_KEY!, - { - cookies: { - getAll() { - return []; - }, - setAll() {}, - }, - } + process.env.SUPABASE_SERVICE_ROLE_KEY! ); }; diff --git a/next.config.ts b/next.config.ts index e9ffa30..fafd533 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + serverExternalPackages: ["@supabase/ssr"], }; export default nextConfig;