claim/DEPLOY_CLOUDFLARE.md
Syazwan 2613c9d337 Refocus repository on Claim App and enable Render GitHub deploys.
Remove ProcureFlow/Celery legacy, Cursor rules bundle, and scratch artifacts; add claim API routes, deploy docs with auto-deploy, and a claim-focused README.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-01 19:58:43 +08:00

1.9 KiB

Deploy Claim App on Cloudflare + MongoDB Atlas

1. MongoDB Atlas

  1. Create a free M0 cluster.
  2. Database user + password.
  3. Network access: allow Cloudflare egress or 0.0.0.0/0 for initial setup.
  4. Copy connection string → MONGO_URL, set DB_NAME=claim.

2. Cloudflare R2

  1. Create bucket (e.g. claim-files).
  2. Create API token with Object Read & Write.
  3. Set R2_* variables on the API host (see backend/.env.example).

3. Google OAuth

  1. Google Cloud Console → OAuth client (Web).
  2. Authorized redirect URI: https://api.YOUR_DOMAIN/api/auth/google/callback
  3. Set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_REDIRECT_URI on API.
  4. Set FRONTEND_URL=https://YOUR_DOMAIN and matching CORS_ORIGINS.

4. API host (FastAPI)

Cloudflare Workers do not run this Python stack natively. Options:

  • Recommended v1: Run uvicorn server:app on Fly.io, Railway, or a small VM; point REACT_APP_BACKEND_URL to that URL.
  • Set all backend/.env variables on the host.
cd backend
pip install -r requirements.txt
uvicorn server:app --host 0.0.0.0 --port 8001

5. Frontend — Cloudflare Pages

cd frontend
yarn install
REACT_APP_BACKEND_URL=https://api.YOUR_DOMAIN yarn build
npx wrangler pages deploy build --project-name=claim-app

frontend/public/_redirects enables SPA routing.

6. Custom domain

  • Pages: claims.yourcompany.com → Cloudflare Pages project.
  • API: api.yourcompany.com → your API host (CNAME).

7. Android APK (Capacitor)

cd frontend
yarn add @capacitor/core @capacitor/cli @capacitor/android
npx cap init "Claim App" com.yourcompany.claim --web-dir build
yarn build
npx cap add android
npx cap sync android
npx cap open android

In capacitor.config.ts, set server.url to your production web URL for live reload, or ship static assets in the APK.