Deployment
Bloomify — Deployment Guide
Step-by-step first deployment from zero to live

Step 1: Create D1 Database

npx wrangler d1 create bloomify_db --env bloomify

Copy the database ID from the output and set it in wrangler.toml under [env.bloomify]:

[env.bloomify]
name = "bloomify-api"

[[env.bloomify.d1_databases]]
binding = "DB"
database_name = "bloomify_db"
database_id = "65ce920d-2760-4918-a32a-e4aef9a58a83"

Step 2: Apply Migrations

npx wrangler d1 execute bloomify_db --file=worker/db/schema.sql --env bloomify

Verify tables exist:

npx wrangler d1 execute bloomify_db --command="SELECT name FROM sqlite_master WHERE type='table';" --env bloomify

Step 3: Seed Admin User

npx wrangler d1 execute bloomify_db --file=worker/db/seed.sql --env bloomify

The seed script creates the admin user. If running manually, do not write a raw password — use the Worker's /api/admin/password endpoint or the seed script which generates the correct saltHex:hashHex hash format.

Step 4: Set JWT Secret

npx wrangler secret put JWT_SECRET --env bloomify
# Paste your secret when prompted — never put it in wrangler.toml

Step 5: Verify CORS Origin in worker.ts

CORS is hardcoded directly in src/worker.ts (not read from wrangler.toml) to prevent env var mismatches from breaking it:

const origin = 'https://bloomifyofficial.sonandigital.com';

Do not change this to env.ALLOWED_ORIGIN. The original bug was caused by the FUSE-safe commit process updating git but not the disk file that wrangler actually reads — meaning the wrong domain kept being deployed silently. Hardcoding eliminates this class of error permanently.

Step 6: Deploy Worker

npx wrangler deploy --env bloomify

Confirm the worker URL in the output (e.g. bloomify-api.<subdomain>.workers.dev).

Step 7: Set Worker Custom Domain

In Cloudflare Dashboard → Workers & Pages → bloomify-api → Settings → Triggers → Custom Domains, add: bloomify-api.sonandigital.com. Cloudflare will provision the DNS record and TLS automatically.

Step 8: Deploy Frontend to Cloudflare Pages

# Build the frontend
npm run build

# The output directory is: dist/

In Cloudflare Dashboard → Workers & Pages → Create Application → Pages → Connect to Git. Select the bloomify-portal repo. Set build command to npm run build and output directory to dist.

Alternatively push to GitHub — Pages auto-deploys on every push to main.

Step 9: Add Pages Custom Domain

In Cloudflare Pages → bloomify-portal → Custom Domains → Add a domain. Enter bloomifyofficial.sonandigital.com. Cloudflare will add the CNAME and provision TLS.

Step 10: Fix .git/config if Needed (FUSE)

If working from the FUSE-mounted workspace, .git/config will be corrupted. Run all of these from a Windows terminal (not from the AI sandbox):

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/bloomify-portal.git
git push origin <commit_sha>:refs/heads/main

Step 11: Verify End-to-End

  • Public site loads at https://bloomifyofficial.sonandigital.com
  • Business name and tagline appear (from Settings via /api/config)
  • Inquiry form submits without CORS error
  • Admin login works at /admin
  • Dashboard shows zero orders (fresh DB)
  • Create a test product, client, order, and invoice
  • Reports page shows the test order revenue