S3-Compatible Storage
Practical storage setup for Bunship: exact env values, R2-first setup, and production validation steps.
If storage is wrong, Bunship will fail in visible places: avatar upload, CMS cover upload, and AI output URLs.
This page focuses on the fastest production-safe setup.
TL;DR (Recommended)
Use Cloudflare R2 first unless your team already runs on AWS.
- lower egress risk in common CDN setups
- fully S3-compatible with Bunship
- quickest path to stable uploads
What Bunship Needs
Bunship only needs these 6 variables to run uploads end-to-end:
S3_ENDPOINTS3_REGIONS3_ACCESS_KEYS3_SECRET_KEYS3_BUCKETNEXT_PUBLIC_S3_URL_BASE
Use NEXT_PUBLIC_S3_URL_BASE (not S3_URL_BASE) as the public URL prefix used by the app.
Quick Setup: Cloudflare R2
1. Create bucket
Create one bucket, for example: bunship-prod.
2. Create API token
Create an R2 API token with read/write access to that bucket.
3. Get endpoint and public URL base
- Endpoint format:
https://<ACCOUNT_ID>.r2.cloudflarestorage.com - Public URL base:
- your CDN/custom domain, or
- R2 public domain (if enabled)
4. Fill environment variables
S3_ENDPOINT="https://<ACCOUNT_ID>.r2.cloudflarestorage.com"
S3_REGION="auto"
S3_ACCESS_KEY="<R2_ACCESS_KEY_ID>"
S3_SECRET_KEY="<R2_SECRET_ACCESS_KEY>"
S3_BUCKET="bunship-prod"
NEXT_PUBLIC_S3_URL_BASE="https://cdn.yourdomain.com"5. Restart web and api services
After env changes, restart both services so upload clients reload config.
Production Validation (Must Pass)
- Upload an image from user flow.
- Upload/generate a CMS post cover from admin.
- Trigger an AI generation task and open returned file URL.
If all 3 succeed, your storage integration is basically healthy.
Common Misconfigurations
403or signature mismatch: endpoint/region/key do not match same provider account.- Upload succeeded but URL is broken:
NEXT_PUBLIC_S3_URL_BASEis wrong or bucket is not public via CDN. - Works locally but fails in production: web/api env variables are inconsistent.
- Sudden cost spike: no CDN caching policy + large media payloads.
When to Choose AWS S3 Instead
Choose S3 directly if you already have:
- existing AWS networking and IAM policy setup
- mandatory AWS compliance requirements
- centralized AWS cost and logging workflows