Cloudflare Setup
Alokai CMS requires three Cloudflare services: D1 (database), R2 (object storage), and KV (cache). Create them before deploying.
Create resources
-
Create a D1 database
Terminal window wrangler d1 create alokon-dbCopy the
database_idfrom the output intowrangler.jsonc:"d1_databases": [{"binding": "DB","database_name": "alokon-db","database_id": "<paste-id-here>"}] -
Create an R2 bucket
Terminal window wrangler r2 bucket create alokon-assets"r2_buckets": [{"binding": "ASSETS","bucket_name": "alokon-assets"}] -
Create a KV namespace
Terminal window wrangler kv namespace create CACHECopy the
idfrom the output:"kv_namespaces": [{"binding": "CACHE","id": "<paste-id-here>"}] -
Run migrations on the remote database
Terminal window wrangler d1 migrations apply alokon-db --remote -
Seed the remote database
Terminal window wrangler d1 execute alokon-db --remote --file=src/db/migrations/002_seed.sql -
Set secrets
Terminal window wrangler secret put AUTH_JWT_SECRET# Enter a long random string when prompted -
Deploy
Terminal window yarn deploy
Custom domain
In the Cloudflare dashboard, go to Workers & Pages → your worker → Settings → Triggers → Custom Domains and add your domain.
CORS
If your storefront is on a different domain than the Worker, configure CORS in src/server/index.ts. The default dev config allows all origins.
Environment variables in production
Set all variables via Wrangler secrets (for sensitive values) or wrangler.jsonc vars (for non-sensitive):
wrangler secret put AUTH_JWT_SECRETwrangler secret put OIDC_ISSUER # if using OIDCNon-sensitive vars can go in wrangler.jsonc under "vars".