Fix build time: env var placeholders + sacar .next del repo

- lib/supabase.ts: ?? placeholders para que el módulo cargue en build
  time sin las env vars; force-dynamic garantiza que nunca se llame
  en build time.
- next.config.ts: env fallbacks vacíos para que Next.js no aborte
  al no encontrar NEXT_PUBLIC_SUPABASE_* en build time.
- .gitignore: agrega .next/ (artefactos de build no van a git).
- git rm --cached .next/**: saca los artefactos ya trackeados.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
markosbenitez
2026-06-02 21:22:55 -03:00
parent df2c33f2d9
commit 10c665d25c
148 changed files with 13 additions and 1649 deletions

View File

@@ -3,15 +3,11 @@ import { createClient as createSupabaseClient } from '@supabase/supabase-js'
// Browser-side client using the anon key (public, respects RLS)
// NEVER put SUPABASE_SERVICE_ROLE_KEY in a NEXT_PUBLIC_ variable or in this file.
export function createClient() {
const url = process.env.NEXT_PUBLIC_SUPABASE_URL
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
if (!url || !anonKey) {
throw new Error(
'Missing NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY. ' +
'Copy .env.example to .env.local and fill in the values from your Supabase project.'
)
}
// Placeholders keep the module loadable at build time (static analysis, standalone output).
// The real values must be set at runtime via .env.local / Dokploy env vars.
// force-dynamic on page.tsx guarantees this function is never *called* at build time.
const url = process.env.NEXT_PUBLIC_SUPABASE_URL ?? 'https://placeholder.supabase.co'
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ?? 'placeholder'
return createSupabaseClient(url, anonKey)
}