Cloudflare init #27
Answered
by
kmsbernard
jamesholcomb
asked this question in
Q&A
|
Hi, have you given thought to implementing a My use case is self hosting locally but fronting the storage domain on Cloudflare.
$ npx cmpatch cloudflare init
┌ Codemagic Patch — Cloudflare CDN & R2 Setup Wizard
│
◇ Checking Wrangler authentication...
│ ✔ Logged in as developer@example.com (Account ID: c3a4...8f91)
│
◇ Select your Cloudflare DNS Zone for OTA static downloads:
│ ○ updates.example.com
│ ● storage.updates.example.com
│
◇ Enter your Cloudflare R2 Bucket name [cmpatch-r2-storage]:
│ └ cmpatch-r2-storage
│
◇ Creating Cloudflare R2 Bucket via Wrangler...
│ $ wrangler r2 bucket create cmpatch-r2-storage
│ ✔ Bucket 'cmpatch-r2-storage' created successfully.
│
◇ Configuring CORS on R2 bucket for React Native clients...
│ ✔ Applied CORS rule (Origins: '*', Methods: ['GET', 'HEAD']).
│
◇ Binding Custom Domain to R2 Bucket...
│ $ wrangler r2 bucket domain add cmpatch-r2-storage --domain storage.updates.example.com
│ ✔ Domain bound to bucket.
│
◇ Setting Cloudflare DNS Record...
│ ✔ CNAME storage.updates.example.com -> cmpatch-r2-storage.r2.cloudflarestorage.com [Proxied: 🟠 True]
│
◇ Configuring Cloudflare Edge Cache Rules for CDN-first manifests...
│ ✔ Rule 1: Static bundles (*.bundle, *.png) -> Cache TTL: 1 Year
│ ✔ Rule 2: Manifests (*meta.json, *manifest.json) -> Edge Cache TTL: 2 Hours (Origin bypass on purge)
│
◇ Generating Cloudflare API Token for automated cache invalidations...
│ ✔ Token created with Zone.Cache Purge permissions.
│
└ Cloudflare setup complete! Updated local `.env.selfhost` with:
• PUBLIC_BASE_URL="https://storage.updates.example.com"
• DELIVERY_ADAPTER="cloudflare"
• CLOUDFLARE_ZONE_ID="z_987654321"
• CLOUDFLARE_PURGE_API_TOKEN="cf_pat_abc123..." |
Answered by
kmsbernard
Aug 28, 2026
Replies: 1 comment
|
Thanks for the suggestion! Improving the setup experience through the CLI is our top priority right now, and it's under active development. Your use case is exactly the kind of thing we want the CLI to do, so I'm adding it to the roadmap. I'll let you know when there's something you can try. |
0 replies
Answer selected by
jamesholcomb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the suggestion!
Improving the setup experience through the CLI is our top priority right now, and it's under active development. Your use case is exactly the kind of thing we want the CLI to do, so I'm adding it to the roadmap.
I'll let you know when there's something you can try.