fix: resolve __dirname error by forcing Node.js runtime on all server routes

- Add serverExternalPackages for @supabase/ssr in next.config.ts
- Add export const runtime = 'nodejs' to all pages/routes using Supabase
- Replace createAdminClient to use @supabase/supabase-js directly (no SSR)
- Prevents @supabase/ssr from running in Edge runtime on Vercel

https://claude.ai/code/session_01H2aRGDaKgarPvhay2HxN6Y
This commit is contained in:
Claude
2026-02-08 19:08:32 +00:00
parent d713f7f5ef
commit ee6870d73e
9 changed files with 19 additions and 11 deletions

View File

@@ -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<Database>(
return createSupabaseClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!,
{
cookies: {
getAll() {
return [];
},
setAll() {},
},
}
process.env.SUPABASE_SERVICE_ROLE_KEY!
);
};