@riligar/agents-kit 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/{skills/riligar-dev-clean-code/SKILL.md → rules/clean-code.md} +3 -51
- package/.agent/skills/riligar-design-system/SKILL.md +1 -0
- package/.agent/skills/riligar-dev-auth-elysia/SKILL.md +2 -2
- package/.agent/skills/riligar-dev-dashboard/SKILL.md +582 -0
- package/.agent/skills/riligar-dev-dashboard/references/dependencies.md +44 -0
- package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/SKILL.md +13 -9
- package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/SKILL.md +1 -1
- package/.agent/skills/{riligar-dev-seo → riligar-dev-website-seo}/SKILL.md +1 -1
- package/.agent/skills/riligar-infra-cloudfare/SKILL.md +437 -0
- package/.agent/skills/riligar-infra-cloudfare/references/cloudflare-api.md +139 -0
- package/.agent/skills/riligar-infra-cloudfare/references/email-routing.md +262 -0
- package/.agent/skills/riligar-infra-cloudfare/references/r2-storage.md +333 -0
- package/.agent/skills/{riligar-infrastructure → riligar-infra-fly}/SKILL.md +38 -1
- package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/SKILL.md +3 -4
- package/.agent/skills/skill-creator/SKILL.md +1 -1
- package/package.json +1 -1
- package/.agent/skills/riligar-dev-architecture/SKILL.md +0 -54
- package/.agent/skills/riligar-dev-architecture/references/context-discovery.md +0 -43
- package/.agent/skills/riligar-dev-architecture/references/examples.md +0 -94
- package/.agent/skills/riligar-dev-architecture/references/pattern-selection.md +0 -68
- package/.agent/skills/riligar-dev-architecture/references/patterns-reference.md +0 -50
- package/.agent/skills/riligar-dev-architecture/references/trade-off-analysis.md +0 -77
- package/.agent/skills/riligar-dev-autopilot/SKILL.md +0 -59
- package/.agent/skills/riligar-dev-code-review/SKILL.md +0 -116
- package/.agent/skills/riligar-dev-database/SKILL.md +0 -51
- package/.agent/skills/riligar-dev-database/references/database-selection.md +0 -43
- package/.agent/skills/riligar-dev-database/references/indexing.md +0 -39
- package/.agent/skills/riligar-dev-database/references/migrations.md +0 -48
- package/.agent/skills/riligar-dev-database/references/optimization.md +0 -36
- package/.agent/skills/riligar-dev-database/references/orm-selection.md +0 -30
- package/.agent/skills/riligar-dev-database/references/schema-design.md +0 -56
- package/.agent/skills/riligar-dev-database/scripts/schema_validator.py +0 -172
- package/.agent/skills/riligar-dev-frontend/SKILL.md +0 -215
- package/.agent/skills/riligar-plan-writing/SKILL.md +0 -162
- package/.agent/skills/riligar-tech-stack/SKILL.md +0 -110
- package/.agent/skills/riligar-tech-stack/references/tech-stack.md +0 -131
- /package/.agent/skills/riligar-dev-auth-elysia/assets/{server-snippets.ts → server-snippets.js} +0 -0
- /package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/references/elysia-basics.md +0 -0
- /package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/references/elysia-lifecycle.md +0 -0
- /package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/references/elysia-patterns.md +0 -0
- /package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/references/elysia-plugins.md +0 -0
- /package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/references/elysia-validation.md +0 -0
- /package/.agent/skills/{riligar-dev-backend → riligar-dev-manager}/scripts/api_validator.py +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-2a03320f967a884fd2ad275d788f32e5.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-481d7179109272dcaff2516fef62b718.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-56d848520060ca714456601d1a7417cd.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-93104cd260129cd6b76dac4119622eaf.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-c5d259b0497cec98c36c48fc33ebbde6.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-e865b2464fdf5ca567af716e1ed4fd16.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-f1459f5315f0045705c2ca4937204146.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/original-f67954754fdc2fc57009369fd3437205.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/screencapture-caddaddy-app-2025-11-03-20_16_14.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/screencapture-ciromaciel-click-2026-01-06-17_08_01.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/screencapture-notionsecondbrain-2026-01-06-16_07_56.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/assets/screencapture-skillsmp-2026-01-16-14_40_22.webp +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/references/conversion-framework.md +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/references/copywriting-guide.md +0 -0
- /package/.agent/skills/{riligar-dev-landing-page → riligar-dev-website}/references/section-blueprints.md +0 -0
- /package/.agent/skills/{riligar-dev-seo → riligar-dev-website-seo}/references/checklist.md +0 -0
- /package/.agent/skills/{riligar-dev-seo → riligar-dev-website-seo}/references/implementation.md +0 -0
- /package/.agent/skills/{riligar-dev-seo → riligar-dev-website-seo}/references/structured-data.md +0 -0
- /package/.agent/skills/{riligar-infrastructure → riligar-infra-fly}/references/infrastructure.md +0 -0
- /package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/assets/stripe-client.js +0 -0
- /package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/assets/stripe-server.js +0 -0
- /package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/references/stripe-database.md +0 -0
- /package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/references/stripe-elysia.md +0 -0
- /package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/references/stripe-react.md +0 -0
- /package/.agent/skills/{riligar-dev-stripe → riligar-infra-stripe}/references/stripe-webhooks.md +0 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: riligar-infra-cloudfare
|
|
3
|
+
description: "Setup domains in Cloudflare with DNS for Clerk, Vercel, and email routing. Use when adding new domains, configuring DNS records, or setting up email redirects."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cloudflare Setup
|
|
7
|
+
|
|
8
|
+
Automate Cloudflare workflows: DNS setup, Clerk integration, Vercel deployment, email routing, and R2 storage.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
### Authentication (Choose One)
|
|
13
|
+
|
|
14
|
+
**Option 1: API Token (Recommended)**
|
|
15
|
+
```bash
|
|
16
|
+
# Add to .env.local
|
|
17
|
+
CLOUDFLARE_API_TOKEN="your-api-token"
|
|
18
|
+
CLOUDFLARE_ACCOUNT_ID="your-account-id"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Create token at: https://dash.cloudflare.com/profile/api-tokens
|
|
22
|
+
Required permissions:
|
|
23
|
+
- Zone:DNS:Edit
|
|
24
|
+
- Zone:Zone:Read
|
|
25
|
+
- Email Routing Addresses:Edit
|
|
26
|
+
- Email Routing Rules:Edit
|
|
27
|
+
- Account:R2:Edit (for R2 storage)
|
|
28
|
+
|
|
29
|
+
**Option 2: Wrangler CLI**
|
|
30
|
+
```bash
|
|
31
|
+
# Install wrangler
|
|
32
|
+
bun add -g wrangler
|
|
33
|
+
|
|
34
|
+
# Login (opens browser)
|
|
35
|
+
wrangler login
|
|
36
|
+
|
|
37
|
+
# Verify
|
|
38
|
+
wrangler whoami
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Other Tools
|
|
42
|
+
```bash
|
|
43
|
+
# Vercel CLI (required)
|
|
44
|
+
bun add -g vercel
|
|
45
|
+
vercel login
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Workflow
|
|
49
|
+
|
|
50
|
+
When setting up a new domain, follow these steps:
|
|
51
|
+
|
|
52
|
+
### Step 1: Gather Information
|
|
53
|
+
|
|
54
|
+
Ask the user for:
|
|
55
|
+
1. **Domain name** (e.g., `example.com`)
|
|
56
|
+
2. **Clerk DNS records** (paste from Clerk dashboard)
|
|
57
|
+
3. **Vercel project name** (e.g., `my-app`)
|
|
58
|
+
4. **Email addresses** to create (e.g., `contact`, `support`)
|
|
59
|
+
5. **Redirect target email** (e.g., `me@gmail.com`)
|
|
60
|
+
|
|
61
|
+
### Step 2: Get Zone ID
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# If using API token
|
|
65
|
+
curl -X GET "https://api.cloudflare.com/client/v4/zones?name=DOMAIN" \
|
|
66
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
67
|
+
-H "Content-Type: application/json" | jq '.result[0].id'
|
|
68
|
+
|
|
69
|
+
# If using wrangler
|
|
70
|
+
wrangler pages project list # Shows associated zones
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 3: Create DNS Records for Clerk
|
|
74
|
+
|
|
75
|
+
Clerk provides specific DNS records for each project. Common patterns:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Example: CNAME record
|
|
79
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
80
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
--data '{
|
|
83
|
+
"type": "CNAME",
|
|
84
|
+
"name": "clerk",
|
|
85
|
+
"content": "frontend-api.clerk.dev",
|
|
86
|
+
"ttl": 1,
|
|
87
|
+
"proxied": false
|
|
88
|
+
}'
|
|
89
|
+
|
|
90
|
+
# Example: TXT record for verification
|
|
91
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
92
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
93
|
+
-H "Content-Type: application/json" \
|
|
94
|
+
--data '{
|
|
95
|
+
"type": "TXT",
|
|
96
|
+
"name": "@",
|
|
97
|
+
"content": "clerk-verification=xxxxx",
|
|
98
|
+
"ttl": 1
|
|
99
|
+
}'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Step 4: Add Domain to Vercel
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Add domain to Vercel project
|
|
106
|
+
vercel domains add DOMAIN --scope=TEAM_SLUG
|
|
107
|
+
|
|
108
|
+
# Or link to specific project
|
|
109
|
+
vercel domains add DOMAIN PROJECT_NAME
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Then create Vercel DNS records:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# A record for root domain
|
|
116
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
117
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
118
|
+
-H "Content-Type: application/json" \
|
|
119
|
+
--data '{
|
|
120
|
+
"type": "A",
|
|
121
|
+
"name": "@",
|
|
122
|
+
"content": "76.76.21.21",
|
|
123
|
+
"ttl": 1,
|
|
124
|
+
"proxied": false
|
|
125
|
+
}'
|
|
126
|
+
|
|
127
|
+
# CNAME for www subdomain
|
|
128
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
129
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
130
|
+
-H "Content-Type: application/json" \
|
|
131
|
+
--data '{
|
|
132
|
+
"type": "CNAME",
|
|
133
|
+
"name": "www",
|
|
134
|
+
"content": "cname.vercel-dns.com",
|
|
135
|
+
"ttl": 1,
|
|
136
|
+
"proxied": false
|
|
137
|
+
}'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Step 5: Setup Email Routing
|
|
141
|
+
|
|
142
|
+
First, enable email routing for the zone (do this in Cloudflare dashboard first time).
|
|
143
|
+
|
|
144
|
+
Then create routing rules:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Create destination address (must be verified first)
|
|
148
|
+
curl -X POST "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/email/routing/addresses" \
|
|
149
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
150
|
+
-H "Content-Type: application/json" \
|
|
151
|
+
--data '{
|
|
152
|
+
"email": "your-main-email@gmail.com"
|
|
153
|
+
}'
|
|
154
|
+
|
|
155
|
+
# Create routing rule for contact@domain.com
|
|
156
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/email/routing/rules" \
|
|
157
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
158
|
+
-H "Content-Type: application/json" \
|
|
159
|
+
--data '{
|
|
160
|
+
"name": "Forward contact",
|
|
161
|
+
"enabled": true,
|
|
162
|
+
"matchers": [{"type": "literal", "field": "to", "value": "contact@DOMAIN"}],
|
|
163
|
+
"actions": [{"type": "forward", "value": ["your-main-email@gmail.com"]}]
|
|
164
|
+
}'
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Required MX records for email routing:
|
|
168
|
+
```bash
|
|
169
|
+
# MX records for Cloudflare Email Routing
|
|
170
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
171
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
172
|
+
-H "Content-Type: application/json" \
|
|
173
|
+
--data '{
|
|
174
|
+
"type": "MX",
|
|
175
|
+
"name": "@",
|
|
176
|
+
"content": "route1.mx.cloudflare.net",
|
|
177
|
+
"priority": 69,
|
|
178
|
+
"ttl": 1
|
|
179
|
+
}'
|
|
180
|
+
|
|
181
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
182
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
183
|
+
-H "Content-Type: application/json" \
|
|
184
|
+
--data '{
|
|
185
|
+
"type": "MX",
|
|
186
|
+
"name": "@",
|
|
187
|
+
"content": "route2.mx.cloudflare.net",
|
|
188
|
+
"priority": 46,
|
|
189
|
+
"ttl": 1
|
|
190
|
+
}'
|
|
191
|
+
|
|
192
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
193
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
194
|
+
-H "Content-Type: application/json" \
|
|
195
|
+
--data '{
|
|
196
|
+
"type": "MX",
|
|
197
|
+
"name": "@",
|
|
198
|
+
"content": "route3.mx.cloudflare.net",
|
|
199
|
+
"priority": 89,
|
|
200
|
+
"ttl": 1
|
|
201
|
+
}'
|
|
202
|
+
|
|
203
|
+
# TXT record for SPF
|
|
204
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
205
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
206
|
+
-H "Content-Type: application/json" \
|
|
207
|
+
--data '{
|
|
208
|
+
"type": "TXT",
|
|
209
|
+
"name": "@",
|
|
210
|
+
"content": "v=spf1 include:_spf.mx.cloudflare.net ~all",
|
|
211
|
+
"ttl": 1
|
|
212
|
+
}'
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Step 6: Verification Checklist
|
|
216
|
+
|
|
217
|
+
After setup, verify:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# List all DNS records
|
|
221
|
+
curl -X GET "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
222
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | jq '.result[] | {type, name, content}'
|
|
223
|
+
|
|
224
|
+
# Check Vercel domain status
|
|
225
|
+
vercel domains inspect DOMAIN
|
|
226
|
+
|
|
227
|
+
# Test email routing (send test email to contact@DOMAIN)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Interactive Prompts Template
|
|
231
|
+
|
|
232
|
+
When running `/cloudflare`, ask:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
What domain are you setting up?
|
|
236
|
+
> example.com
|
|
237
|
+
|
|
238
|
+
Paste the Clerk DNS records from your Clerk dashboard:
|
|
239
|
+
> [user pastes records]
|
|
240
|
+
|
|
241
|
+
What's the Vercel project name?
|
|
242
|
+
> my-saas-app
|
|
243
|
+
|
|
244
|
+
What email addresses should I create? (comma-separated)
|
|
245
|
+
> contact, support, hello
|
|
246
|
+
|
|
247
|
+
What email should these redirect to?
|
|
248
|
+
> myemail@gmail.com
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Common DNS Record Types
|
|
252
|
+
|
|
253
|
+
| Type | Use Case | Proxied |
|
|
254
|
+
|------|----------|---------|
|
|
255
|
+
| A | Root domain to IP | No (for Vercel) |
|
|
256
|
+
| CNAME | Subdomain to hostname | No (for Clerk/Vercel) |
|
|
257
|
+
| TXT | Verification, SPF | N/A |
|
|
258
|
+
| MX | Email routing | N/A |
|
|
259
|
+
|
|
260
|
+
## Troubleshooting
|
|
261
|
+
|
|
262
|
+
| Issue | Solution |
|
|
263
|
+
|-------|----------|
|
|
264
|
+
| Zone not found | Domain must be added to Cloudflare first |
|
|
265
|
+
| DNS propagation slow | Wait 5-10 minutes, check with `dig` |
|
|
266
|
+
| Email not forwarding | Verify destination email first |
|
|
267
|
+
| Vercel 404 | Check DNS proxied=false for Vercel records |
|
|
268
|
+
| Clerk verification failed | Ensure TXT record is on root (@) |
|
|
269
|
+
|
|
270
|
+
## Useful Commands
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Check DNS propagation
|
|
274
|
+
dig DOMAIN +short
|
|
275
|
+
dig DOMAIN MX +short
|
|
276
|
+
dig DOMAIN TXT +short
|
|
277
|
+
|
|
278
|
+
# List zones in account
|
|
279
|
+
curl -X GET "https://api.cloudflare.com/client/v4/zones" \
|
|
280
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | jq '.result[] | {name, id}'
|
|
281
|
+
|
|
282
|
+
# Delete a DNS record
|
|
283
|
+
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records/RECORD_ID" \
|
|
284
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
# R2 Storage Setup
|
|
290
|
+
|
|
291
|
+
Setup R2 buckets for file storage: user uploads, static assets, backups.
|
|
292
|
+
|
|
293
|
+
## R2 Workflow
|
|
294
|
+
|
|
295
|
+
### Step 1: Determine Use Case
|
|
296
|
+
|
|
297
|
+
Ask the user:
|
|
298
|
+
```
|
|
299
|
+
What do you want to do with R2?
|
|
300
|
+
1. Create new bucket (full setup)
|
|
301
|
+
2. Configure existing bucket (CORS, public access)
|
|
302
|
+
3. Setup custom domain for bucket
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Step 2: Gather Bucket Info
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
Bucket name?
|
|
309
|
+
> my-app-uploads
|
|
310
|
+
|
|
311
|
+
What will this bucket store?
|
|
312
|
+
1. User uploads (images, files) - needs CORS + presigned URLs
|
|
313
|
+
2. Static assets (public CDN) - needs public access
|
|
314
|
+
3. Backups (private) - no public access
|
|
315
|
+
> 1
|
|
316
|
+
|
|
317
|
+
Custom domain? (optional, press enter to skip)
|
|
318
|
+
> uploads.myapp.com
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Step 3: Create Bucket
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# Create bucket via wrangler
|
|
325
|
+
wrangler r2 bucket create my-app-uploads
|
|
326
|
+
|
|
327
|
+
# Or via API
|
|
328
|
+
curl -X PUT "https://api.cloudflare.com/client/v4/accounts/{account_id}/r2/buckets" \
|
|
329
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
330
|
+
-H "Content-Type: application/json" \
|
|
331
|
+
--data '{"name": "my-app-uploads", "locationHint": "wnam"}'
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Step 4: Configure CORS (for user uploads)
|
|
335
|
+
|
|
336
|
+
Create `cors.json`:
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"corsRules": [
|
|
340
|
+
{
|
|
341
|
+
"allowedOrigins": ["https://myapp.com", "http://localhost:3000"],
|
|
342
|
+
"allowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
|
|
343
|
+
"allowedHeaders": ["*"],
|
|
344
|
+
"exposeHeaders": ["ETag", "Content-Length"],
|
|
345
|
+
"maxAgeSeconds": 3600
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Apply CORS:
|
|
352
|
+
```bash
|
|
353
|
+
wrangler r2 bucket cors put my-app-uploads --file=cors.json
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Step 5: Setup Public Access (for static assets)
|
|
357
|
+
|
|
358
|
+
Option A: Enable R2.dev subdomain (via dashboard)
|
|
359
|
+
- Go to R2 > Bucket > Settings > Public access
|
|
360
|
+
|
|
361
|
+
Option B: Custom domain:
|
|
362
|
+
```bash
|
|
363
|
+
# Add CNAME record
|
|
364
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
|
|
365
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
366
|
+
-H "Content-Type: application/json" \
|
|
367
|
+
--data '{
|
|
368
|
+
"type": "CNAME",
|
|
369
|
+
"name": "uploads",
|
|
370
|
+
"content": "{account_id}.r2.cloudflarestorage.com",
|
|
371
|
+
"ttl": 1,
|
|
372
|
+
"proxied": true
|
|
373
|
+
}'
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Then enable custom domain in R2 bucket settings.
|
|
377
|
+
|
|
378
|
+
### Step 6: Generate S3 API Credentials (for SDK access)
|
|
379
|
+
|
|
380
|
+
1. Go to R2 > Manage R2 API Tokens
|
|
381
|
+
2. Create token with Object Read & Write
|
|
382
|
+
3. Add to `.env.local`:
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
R2_ACCESS_KEY_ID="your-access-key"
|
|
386
|
+
R2_SECRET_ACCESS_KEY="your-secret-key"
|
|
387
|
+
R2_ENDPOINT="https://{account_id}.r2.cloudflarestorage.com"
|
|
388
|
+
R2_BUCKET_NAME="my-app-uploads"
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## R2 Quick Commands
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
# List buckets
|
|
395
|
+
wrangler r2 bucket list
|
|
396
|
+
|
|
397
|
+
# Create bucket
|
|
398
|
+
wrangler r2 bucket create BUCKET_NAME
|
|
399
|
+
|
|
400
|
+
# Delete bucket
|
|
401
|
+
wrangler r2 bucket delete BUCKET_NAME
|
|
402
|
+
|
|
403
|
+
# List objects
|
|
404
|
+
wrangler r2 object list BUCKET_NAME
|
|
405
|
+
|
|
406
|
+
# Upload file
|
|
407
|
+
wrangler r2 object put BUCKET_NAME/path/file.png --file=./local.png
|
|
408
|
+
|
|
409
|
+
# View CORS config
|
|
410
|
+
wrangler r2 bucket cors get BUCKET_NAME
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## R2 Use Case Presets
|
|
414
|
+
|
|
415
|
+
| Use Case | CORS | Public | Custom Domain |
|
|
416
|
+
|----------|------|--------|---------------|
|
|
417
|
+
| User uploads | Yes | No | Optional |
|
|
418
|
+
| Static assets/CDN | No | Yes | Recommended |
|
|
419
|
+
| Backups | No | No | No |
|
|
420
|
+
| Public downloads | No | Yes | Optional |
|
|
421
|
+
|
|
422
|
+
## R2 Troubleshooting
|
|
423
|
+
|
|
424
|
+
| Issue | Solution |
|
|
425
|
+
|-------|----------|
|
|
426
|
+
| CORS error in browser | Add domain to allowedOrigins |
|
|
427
|
+
| 403 Forbidden | Check API token has R2:Edit permission |
|
|
428
|
+
| Custom domain not working | Ensure CNAME is proxied (orange cloud) |
|
|
429
|
+
| Upload fails | Verify Content-Type header matches file |
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## References
|
|
434
|
+
|
|
435
|
+
- **[Cloudflare API Reference](references/cloudflare-api.md)**: Auth tokens, zone operations, DNS endpoints
|
|
436
|
+
- **[Email Routing](references/email-routing.md)**: Email forwarding setup and configuration
|
|
437
|
+
- **[R2 Storage](references/r2-storage.md)**: Bucket management, CORS, presigned URLs
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Cloudflare API Reference
|
|
2
|
+
|
|
3
|
+
## Authentication
|
|
4
|
+
|
|
5
|
+
### API Token (Recommended)
|
|
6
|
+
```bash
|
|
7
|
+
# Header format
|
|
8
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Create at: https://dash.cloudflare.com/profile/api-tokens
|
|
12
|
+
|
|
13
|
+
Required permissions:
|
|
14
|
+
- **Zone:DNS:Edit** - Create/modify DNS records
|
|
15
|
+
- **Zone:Zone:Read** - List and read zone info
|
|
16
|
+
- **Account:Email Routing Addresses:Edit** - Manage destination emails
|
|
17
|
+
- **Zone:Email Routing Rules:Edit** - Create routing rules
|
|
18
|
+
|
|
19
|
+
### Global API Key (Legacy)
|
|
20
|
+
```bash
|
|
21
|
+
-H "X-Auth-Email: your@email.com"
|
|
22
|
+
-H "X-Auth-Key: your-global-api-key"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Base URL
|
|
26
|
+
```
|
|
27
|
+
https://api.cloudflare.com/client/v4
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Zone Operations
|
|
31
|
+
|
|
32
|
+
### List Zones
|
|
33
|
+
```bash
|
|
34
|
+
curl -X GET "https://api.cloudflare.com/client/v4/zones" \
|
|
35
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
36
|
+
-H "Content-Type: application/json"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Get Zone by Domain
|
|
40
|
+
```bash
|
|
41
|
+
curl -X GET "https://api.cloudflare.com/client/v4/zones?name=example.com" \
|
|
42
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Response:
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"result": [{
|
|
49
|
+
"id": "zone-id-here",
|
|
50
|
+
"name": "example.com",
|
|
51
|
+
"status": "active"
|
|
52
|
+
}]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## DNS Record Operations
|
|
57
|
+
|
|
58
|
+
### List DNS Records
|
|
59
|
+
```bash
|
|
60
|
+
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
|
|
61
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Create DNS Record
|
|
65
|
+
```bash
|
|
66
|
+
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
|
|
67
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
68
|
+
-H "Content-Type: application/json" \
|
|
69
|
+
--data '{
|
|
70
|
+
"type": "A",
|
|
71
|
+
"name": "@",
|
|
72
|
+
"content": "192.0.2.1",
|
|
73
|
+
"ttl": 1,
|
|
74
|
+
"proxied": false
|
|
75
|
+
}'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Record Types
|
|
79
|
+
|
|
80
|
+
| Type | Fields | Example Content |
|
|
81
|
+
|------|--------|-----------------|
|
|
82
|
+
| A | name, content, ttl, proxied | `192.0.2.1` |
|
|
83
|
+
| AAAA | name, content, ttl, proxied | `2001:db8::1` |
|
|
84
|
+
| CNAME | name, content, ttl, proxied | `target.example.com` |
|
|
85
|
+
| TXT | name, content, ttl | `v=spf1 include:...` |
|
|
86
|
+
| MX | name, content, priority, ttl | `mail.example.com` |
|
|
87
|
+
|
|
88
|
+
### Special Name Values
|
|
89
|
+
- `@` - Root domain
|
|
90
|
+
- `*` - Wildcard
|
|
91
|
+
- `subdomain` - Specific subdomain
|
|
92
|
+
|
|
93
|
+
### TTL Values
|
|
94
|
+
- `1` - Automatic (recommended)
|
|
95
|
+
- `60` - 1 minute
|
|
96
|
+
- `3600` - 1 hour
|
|
97
|
+
- `86400` - 1 day
|
|
98
|
+
|
|
99
|
+
### Update DNS Record
|
|
100
|
+
```bash
|
|
101
|
+
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records/{record_id}" \
|
|
102
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
103
|
+
-H "Content-Type: application/json" \
|
|
104
|
+
--data '{
|
|
105
|
+
"content": "new-value"
|
|
106
|
+
}'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Delete DNS Record
|
|
110
|
+
```bash
|
|
111
|
+
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records/{record_id}" \
|
|
112
|
+
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Error Handling
|
|
116
|
+
|
|
117
|
+
### Response Format
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"success": true,
|
|
121
|
+
"errors": [],
|
|
122
|
+
"messages": [],
|
|
123
|
+
"result": { ... }
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Common Errors
|
|
128
|
+
|
|
129
|
+
| Code | Message | Solution |
|
|
130
|
+
|------|---------|----------|
|
|
131
|
+
| 9109 | Invalid access token | Check token permissions |
|
|
132
|
+
| 81057 | Record already exists | Delete or update existing |
|
|
133
|
+
| 1004 | DNS validation error | Check record format |
|
|
134
|
+
|
|
135
|
+
## Rate Limits
|
|
136
|
+
|
|
137
|
+
- 1200 requests per 5 minutes per user
|
|
138
|
+
- Applies across all API endpoints
|
|
139
|
+
- Returns `429 Too Many Requests` when exceeded
|