Next.js web app for challenges.terraserve.org — environmental and medical volunteer challenges with verified hours and certificates.
- Copy
.env.exampleto.env.localand fill in Supabase + admin email values. - Apply the database schema — either:
- CLI (recommended): add your database connection string to
.env.local, then:No# Dashboard → Settings → Database → Session pooler (port 5432) # Add to .env.local: SUPABASE_DB_URL=postgresql://postgres.zfexfatuhcqmwozouwtk:... npm run db:push
supabase loginorsupabase linkrequired — only the database password. - SQL Editor (fresh project): run
supabase/RUN_IN_SQL_EDITOR.sql, then all migrations insupabase/migrations/in filename order.RUN_IN_SQL_EDITOR.sqlalone does not create partner tables or homepage testimonials. - SQL Editor (existing DB, partner only): run
supabase/scripts/APPLY_PARTNER_SETUP_ALL.sql, then apply any newer migrations (e.g.20260702120000_testimonial_avatars_and_storage.sql).
- CLI (recommended): add your database connection string to
- Verify:
npm run verify:supabase(loads.env.localautomatically) - Sync admin emails: every address in
ADMIN_EMAILSmust exist inchallenge_admins(seesupabase/scripts/sync-challenge-admins.sql). Without this,/adminloads but RPC actions fail with Forbidden. - If partners signed up before the partner migration, run
supabase/scripts/backfill-broken-partner-profiles.sql. - Full SQL audit (optional): run
supabase/scripts/diagnose-deployment.sqlin the Supabase SQL Editor. - Configure Supabase Auth for password reset and signup emails (see Auth email below).
Password reset and signup confirmation emails are sent by Supabase Auth, not Resend. App transactional mail (submission approved, partner approved, etc.) uses Resend separately.
- Supabase Dashboard → Authentication → URL configuration
- Site URL:
https://challenges.terraserve.org(or your staging URL) - Redirect URLs: include
https://challenges.terraserve.org/auth/callbackandhttp://localhost:3000/auth/callback
- Site URL:
- Authentication → Email
- Enable custom SMTP (recommended for production) or verify Supabase’s default sender is delivering to your inbox (check spam).
- Customize the Reset password template if needed; the link must use the project’s redirect allow-list.
- Local dev:
supabase/config.tomlhas SMTP commented out andenable_confirmations = false— reset emails in local dev require enabling SMTP or testing against the hosted project. - After reset, users land on
/auth/update-passwordto set a new password, then are routed to/dashboardor/partnerby account type.
APPLY_PARTNER_SETUP_ALL.sql— if partner setup not yet applied- New migrations via
npm run db:pushor paste in SQL Editor (includes testimonial photos + avatars storage) sync-challenge-admins.sql— add allADMIN_EMAILSnpm run verify:supabasediagnose-deployment.sql— full read-only audit
Cannot find project ref→ usenpm run db:pushwithSUPABASE_DB_URLin.env.local(no link needed).Your account does not have the necessary privileges→ ignoresupabase link; setSUPABASE_DB_URLinstead and runnpm run db:push.failed to connect to postgres→ copy the Session pooler URI (port 5432) from the dashboard; check region in the hostname matches your project.
npm install
npm run devOpen http://localhost:3000.
- Import this repo in Vercel.
- Set environment variables from
.env.example(setNEXT_PUBLIC_SITE_URL=https://challenges.terraserve.org). - Add custom domain
challenges.terraserve.orgin Vercel → Project → Settings → Domains. - In your DNS provider for
terraserve.org, add a CNAME record:- Name:
challenges - Value: the target Vercel shows (usually
cname.vercel-dns.com)
- Name:
- After DNS propagates, verify:
https://challenges.terraserve.org/robots.txthttps://challenges.terraserve.org/sitemap.xml
- Deploy Supabase Edge Functions from
supabase/functions/if using serverless email/review paths.
- Next.js App Router + TypeScript + Tailwind CSS v4
- Supabase Auth, Postgres, Storage, Realtime
- Resend for transactional email