Ingest Admin β Frontend (Next.js) Quickstart
Purpose
- Example Next.js admin panel with Supabase auth and server-side proxy routes that forward admin actions to the Python ingest API.
Key files (in this repo)
admin-nextjs-example/pages/admin.jsβ Admin UI (magic-link sign-in via Supabase, triggers ingest actions).admin-nextjs-example/pages/api/proxy/ingest-url.jsβ Server proxy for URL ingest (verifies Supabase token, forwards to Python API with server-side key).admin-nextjs-example/pages/api/proxy/ingest-pdf.jsβ Server proxy for PDF uploads (parses multipart withformidable, forwards to Python API with server-side key).
Environment variables (Next.js server)
NEXT_PUBLIC_SUPABASE_URLβ Supabase project URL (client)NEXT_PUBLIC_SUPABASE_ANON_KEYβ Supabase anon key (client)SUPABASE_SERVICE_ROLE_KEYβ Supabase service role key (server-only; used to verify tokens)INGEST_API_URLβ URL of Python ingest service (server-only)INGEST_API_KEYβ Admin API key for Python ingest service (server-only)
Optional (client direct upload)
NEXT_PUBLIC_INGEST_API_URLandNEXT_PUBLIC_INGEST_API_KEY(only for testing; DO NOT expose in production)
Install
# in your Next.js project
npm install @supabase/supabase-js formidable form-data
Run
# set env vars in .env.local or host environment
npm run dev
How it works
- Admin UI uses Supabase magic-link auth. After sign-in the client receives an access token.
- Client calls server proxy endpoints with
Authorization: Bearer <access_token>. - Server proxy verifies token using
SUPABASE_SERVICE_ROLE_KEYand then forwards request to Python ingest API usingINGEST_API_KEYkept server-side.
Security notes
- Never expose
SUPABASE_SERVICE_ROLE_KEYorINGEST_API_KEYto the browser. - Only allow trusted admin users in Supabase (use roles or check email against allowlist in proxy route).
Next steps / customization
- Add an allowlist in
ingest-url.jsandingest-pdf.jsto restrict which Supabase users can trigger ingests. - Add a jobs dashboard that polls
GET /jobs/{job_id}and displays status/history. - Integrate Supabase Row Level Security (RLS) if storing job records in Supabase DB.
Notes
- The example
ingest-pdfproxy usesformidableto parse uploads andform-datato forward files; ensure Node environment has permissions to write temp files. - For serverless deployments, adjust temp file handling per platform.