Webapp en Next.js para crear y jugar porras privadas de fútbol y Formula 1.
- Next.js App Router
- NextAuth (Google)
- MongoDB Atlas
- Stripe Checkout + Webhook
- TheSportsDB
npm install
cp .env.example .env.local
npm run devVariables esperadas en .env.local:
AUTH_SECRET=
AUTH_TRUST_HOST=true
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
MONGODB_URI=
MONGODB_DB=porra
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
NEXT_PUBLIC_APP_URL=http://localhost:3000
THESPORTSDB_API_KEY=
CRON_SECRET=- Callback URL:
http://localhost:3000/api/auth/callback/google
stripe listen --forward-to localhost:3000/api/stripe/webhookCopia el whsec_... que devuelve Stripe en STRIPE_WEBHOOK_SECRET.
- Sube este repositorio a GitHub.
- En Vercel,
Add New -> Projecty selecciona el repo. - En
Environment Variables, añade todas las variables de.env.example. - Ajusta estas URLs de producción:
NEXT_PUBLIC_APP_URL=https://tu-dominio.vercel.app- Google OAuth Authorized redirect URI:
https://tu-dominio.vercel.app/api/auth/callback/google
- Deploy.
- En Stripe Dashboard, crea endpoint webhook:
- URL:
https://tu-dominio.vercel.app/api/stripe/webhook
- URL:
- Eventos mínimos recomendados:
checkout.session.completedcheckout.session.expired
- Copia el secret del endpoint en Vercel como
STRIPE_WEBHOOK_SECRET. - Usa
STRIPE_SECRET_KEYen modo live o test según el entorno.
La app incluye endpoint programado en /api/cron/sync.
- Define
CRON_SECRETen Vercel (Environment Variables). - El cron está configurado en
vercel.jsonpara ejecutarse cada día en UTC:0 6 * * *0 12 * * *0 21 * * *
- Estos horarios equivalen actualmente (Europa/Madrid en horario de verano) a:
08:00,14:00y23:00.
También puedes lanzar sync manual desde /admin.
usersporrasentriespaymentsteamProgresssyncLogs