Last updated: 2026-07-12
Run all commands from Windows terminal in E:\Claude_Projects\sonan-trackers\lawncare-portal unless otherwise noted. The sandbox gets a 403 on git push — always hand off push commands to the user.
First Deploy (New Environment)
# 1. Apply all D1 migrations on remote database
npx wrangler d1 migrations apply lawncare_db --remote --env bernies
# 2. Set JWT secret (enter a long random string when prompted)
npx wrangler secret put JWT_SECRET --env bernies
# 3. Deploy Worker
npx wrangler deploy --env bernies
# 4. Push code to GitHub (fixes .git/config corruption first — see sequence below)
del .git\config.lock
echo [core] > .git\config
echo repositoryformatversion = 0 >> .git\config
echo filemode = false >> .git\config
echo bare = false >> .git\config
git remote add origin https://github.com/sonantechai/lawncare-portal.git
git push origin <SHA>:refs/heads/main
Cloudflare Pages Setup
| Setting | Value |
|---|---|
| GitHub repo + branch | sonantechai/lawncare-portal → main |
| Framework preset | None (Vite) |
| Build command | npm run build |
| Output directory | dist (no trailing space — Pages is sensitive to this) |
| Environment variable | VITE_API_URL = https://bernies-api.sonandigital.com |
Cloudflare Pages auto-deploys on every push to the main branch. Check the Pages dashboard for build logs if a deploy fails.
Custom Domain
In the Cloudflare Pages project, go to Custom Domains → Add domain. Enter bernies.sonandigital.com. Cloudflare handles DNS automatically since the domain is also on the same Cloudflare account. Worker custom domain (bernies-api.sonandigital.com) is configured in wrangler.toml under the [env.bernies.routes] or routes field.
Ongoing Deploys (Code Changes)
# After FUSE-safe commit (Claude provides SHA):
git push origin <SHA>:refs/heads/main
# Pages auto-rebuilds. If Worker changed:
npx wrangler deploy --env bernies
Running New Migrations
# Check pending migrations
npx wrangler d1 migrations list lawncare_db --remote --env bernies
# Apply pending
npx wrangler d1 migrations apply lawncare_db --remote --env bernies
Post-Deploy Checklist
| Step | Action |
|---|---|
| 1 | Visit bernies.sonandigital.com — public site loads with business info from Settings seed |
| 2 | Click Admin Login → enter Admin@2026 → verify dashboard loads |
| 3 | Go to Settings → update business name, phone, email, address, service types |
| 4 | Settings → Change Password — set a strong unique password |
| 5 | Optionally upload a business logo in Settings |
| 6 | Create a test client, job, estimate, and invoice to verify all modules are working |
| 7 | Submit a test estimate request from the public site — verify it appears in Service Requests |
Rollback
To revert a bad deploy: in the Cloudflare Pages dashboard, find the previous successful deployment and click Rollback to this deployment. For Worker rollbacks: npx wrangler rollback --env bernies. Database changes (D1 migrations) cannot be automatically rolled back — apply a corrective migration manually.