-
Notifications
You must be signed in to change notification settings - Fork 15
Setup Guide
Click the Deploy to Cloudflare button in the README. Cloudflare will:
- Fork the repo into your GitHub account
- Provision a D1 database and Vectorize index
- Prompt you to set an AUTH_TOKEN
- Deploy the Worker automatically
When you click Deploy, you'll see a configuration form. The only required input is:
AUTH_TOKEN — Choose one of these options:
-
Simple: Use a memorable phrase like
coffee-lover-2026 -
Secure: Open your terminal, run
openssl rand -base64 32, and paste the result - Online: Use this generator (opens in new tab) Save your token! You'll need it multiple times to connect AI clients.
Find your Worker URL in Cloudflare Dashboard → Workers & Pages → second-brain. It looks like https://second-brain.<your-subdomain>.workers.dev.
That's it! The database schema auto-creates on your first request. No manual SQL or secret commands needed.
# Use the token you chose during deployment
curl -X POST https://<your-worker-url>/capture \
-H "Authorization: Bearer coffee-lover-2026" \
-H "Content-Type: application/json" \
-d '{"content": "second brain is working", "source": "test"}'
# → {"ok":true,"id":"..."}Then open https://<your-worker-url>/ to access the dashboard.
Manual setup (advanced)
If you prefer to deploy from a local clone or need more control:- Node.js 18+
- A Cloudflare account (free tier works)
- Wrangler CLI (installed via
npm install)
# 1. Clone and install
git clone https://github.com/rahilp/second-brain-cloudflare.git
cd second-brain-cloudflare
npm install
# 2. Authenticate with Cloudflare
npx wrangler login
# 3. Create the D1 database
npm run db:create
# Copy the database_id from the output and paste it into wrangler.toml
# 4. Create the Vectorize index
npm run vectors:create
# 5. Set your auth token (schema will auto-create on first request)
openssl rand -base64 32 # Save this token!
npx wrangler secret put AUTH_TOKEN
# 6. Deploy
npm run deployNote: You no longer need to manually run the schema migration. The Worker will auto-create the table and indexes on first request.
| Script | Description |
|---|---|
npm run dev |
Start local dev server |
npm run deploy |
Deploy to Cloudflare |
npm run db:create |
Create the D1 database |
npm run db:migrate |
Run schema against local D1 (optional) |
npm run db:migrate:remote |
Run schema against remote D1 (optional) |
npm run vectors:create |
Create the Vectorize index |
Local development
```bash npm run dev ```The schema will auto-create on your first request to the local Worker.
Vectorize and Workers AI are only available remotely. Embedding calls will fail gracefully during local development — entries will still be stored in D1 without vectors.
To test against your live remote resources:
npx wrangler dev --remoteTroubleshooting
### "Unauthorized" errorMake sure you're using the correct AUTH_TOKEN. If you forgot it:
- Go to Cloudflare Dashboard → Workers & Pages →
second-brain→ Settings → Variables - Delete the old AUTH_TOKEN secret
- Add a new one with your desired token
The table should auto-create on first request. If you're getting errors, you can manually create it:
npm run db:migrate:remote# For manual setup users
npx wrangler secret put AUTH_TOKEN
# For Deploy button users
# Go to Cloudflare Dashboard → Workers → Settings → Variables → Edit AUTH_TOKEN