diff --git a/backend/lib/supabase.js b/backend/lib/supabase.js index fbc631e..26a1e9a 100644 --- a/backend/lib/supabase.js +++ b/backend/lib/supabase.js @@ -1,7 +1,11 @@ import { createClient } from '@supabase/supabase-js' +const url = process.env.SUPABASE_URL +const key = process.env.SUPABASE_SERVICE_ROLE_KEY + +if (!url || !key) { + throw new Error('Faltan variables de entorno: SUPABASE_URL y/o SUPABASE_SERVICE_ROLE_KEY') +} + // Service Role key: bypasea RLS, solo usar en backend -export const supabase = createClient( - process.env.SUPABASE_URL, - process.env.SUPABASE_SERVICE_ROLE_KEY -) +export const supabase = createClient(url, key) diff --git a/vercel.json b/vercel.json index 9d5ca1e..7614ef8 100644 --- a/vercel.json +++ b/vercel.json @@ -5,6 +5,7 @@ "api/**/*.js": { "maxDuration": 60 } }, "rewrites": [ - { "source": "/:path*", "destination": "/index.html" } + { "source": "/api/(.*)", "destination": "/api/$1" }, + { "source": "/((?!api/).*)", "destination": "/index.html" } ] }