Cloudflare Worker API built with Hono, Supabase Auth, and Google Gemini from @open-templates. Pairs with react-supabase-auth-ai-chat-template.
- Use this template on GitHub, then clone your repo.
- Personalize from
templates/:
./scripts/init-from-template.sh- Install and run:
npm install
cp .env.example .dev.vars
# Set SUPABASE_* and GEMINI_API_KEY in .dev.vars
npm run devSee templates/ABOUT_TEMPLATES.md and docs/INIT_TEMPLATE.md.
| Endpoint | Auth | Description |
|---|---|---|
GET /health |
Public | Liveness check for frontend online/offline indicator |
GET /me |
Bearer JWT | Returns the authenticated Supabase user profile |
POST /chat |
Bearer JWT | Send { "message": "..." } to Gemini; returns model reply |
GET /chat?message=... |
Bearer JWT | Query-string alternative for quick tests |
See index.md for detailed behavior and extension guidance.
Test:
curl http://localhost:8787/health
# With a Supabase access token:
curl -X POST http://localhost:8787/chat \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{"message":"Hello from the worker"}'Full setup: QUICKSTART.md · Cloudflare deploy: CLOUDFLARE_SETUP.md
| Variable | Required | Purpose |
|---|---|---|
SUPABASE_URL |
Yes | Supabase project URL |
SUPABASE_ANON_KEY |
Yes | Anon key for JWT-scoped client |
SUPABASE_SERVICE_ROLE_KEY |
Yes | Reserved for future admin operations |
GEMINI_API_KEY |
Yes | Google AI Studio key for @google/genai |
GEMINI_MODEL |
No | Model id (default gemini-2.5-flash) |
ALLOWED_ORIGINS |
No | Comma-separated CORS origins |
ENVIRONMENT |
No | development / staging / production |
MIT