Dyeink uses Cloudflare R2 for storing images, media files, and other user-uploaded content. R2 is S3-compatible and includes free egress, making it cost-effective for serving blog assets.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/subratomandal/dyeink/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Cloudflare account (sign up at cloudflare.com)
- Access to Cloudflare dashboard with billing configured
- R2 subscription enabled (includes generous free tier)
Enable R2 in Cloudflare
Subscribe to R2
- Log in to your Cloudflare dashboard
- Navigate to R2 from the sidebar
- Click Purchase R2 Plan if not already enabled
- Review pricing and click Proceed
R2 includes 10 GB storage and 1 million Class A operations free per month. Perfect for getting started.
Create R2 Bucket
Create a new bucket
- In the R2 dashboard, click Create bucket
- Choose a unique bucket name:
- Development:
dyeink-dev-uploads - Production:
dyeink-uploadsordyeink-images
- Development:
- Select a location hint (choose closest to your users)
- Click Create bucket
Bucket names must be globally unique across all Cloudflare R2 buckets and follow DNS naming conventions.
Configure Public Access
Enable public access (optional)
For serving public images and assets:
- In your bucket, navigate to Settings > Public access
- Click Allow Access
- You’ll receive a public bucket URL:
Custom domain (recommended)
For a branded URL like
cdn.yourblog.com:- In bucket settings, go to Settings > Custom Domains
- Click Connect Domain
- Enter your custom domain (e.g.,
cdn.yourblog.com) - Follow the DNS configuration instructions
- Add the provided CNAME record to your domain’s DNS:
- Click Continue and wait for DNS propagation
Generate API Credentials
Create R2 API token
- Navigate to R2 > Overview
- Click Manage R2 API Tokens on the right sidebar
- Click Create API token
- Configure the token:
- Token name:
Dyeink Production(or appropriate name) - Permissions:
- Select Object Read & Write
- TTL: Leave as “Forever” or set expiration
- Bucket scope: Select specific buckets or all buckets
- Token name:
- Click Create API Token
Environment Configuration
Backend (backend/.env)
Root (.env)
S3-Compatible Client Setup
R2 is S3-compatible, so you can use standard S3 client libraries.- AWS SDK v3 (Node.js)
- AWS SDK v2 (Node.js)
Configure CORS
If your frontend needs direct access to R2, configure CORS settings.Set CORS policy
- Navigate to your bucket in the R2 dashboard
- Go to Settings > CORS policy
- Add a CORS rule:
- Click Save
CDN and Caching
R2 integrates seamlessly with Cloudflare’s CDN for optimal performance.Enable Cloudflare CDN
If using a custom domain:
- Ensure your domain is proxied through Cloudflare (orange cloud icon)
- Cloudflare will automatically cache static assets
- Configure cache rules in Caching > Configuration
Verification
Verify in dashboard
- Navigate to your bucket in R2 dashboard
- You should see
test.txtin the object list - Click on it to view details and download
Best Practices
Example: Image Upload with Optimization
Troubleshooting
403 Forbidden errors
403 Forbidden errors
- Verify R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY are correct
- Check that the API token has appropriate permissions
- Ensure the bucket name matches exactly
- Verify the token hasn’t expired
CORS errors
CORS errors
- Verify CORS policy is configured in bucket settings
- Check that AllowedOrigins matches your frontend domain exactly
- Ensure AllowedMethods includes the HTTP method you’re using
- Clear browser cache and try again
Public URL returns 404
Public URL returns 404
- Verify public access is enabled for the bucket
- Check that the object key (filename) is correct
- Ensure the file was uploaded successfully (check R2 dashboard)
- Wait a few minutes for DNS propagation if using custom domain
Slow upload/download speeds
Slow upload/download speeds
- Check your network connection
- Verify you’re using the correct region endpoint
- Consider using Cloudflare’s CDN with a custom domain
- Implement multipart uploads for large files
Cost Optimization
R2 pricing (as of 2026):
- Storage: $0.015/GB/month (first 10 GB free)
- Class A operations (writes): $4.50/million (first 1M free)
- Class B operations (reads): $0.36/million (first 10M free)
- Egress: FREE (no bandwidth charges)
Security Best Practices
Next Steps
Deployment
Deploy your Dyeink platform to production
Auth0 Setup
Configure authentication and authorization

