CloudSyncPro stores all user files in Cloudflare R2 — an S3-compatible object store with no egress fees. Files are never uploaded through Supabase; instead, theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/S4nti4goCoder/cloudsyncpro/llms.txt
Use this file to discover all available pages before exploring further.
upload-file Edge Function generates a short-lived presigned URL and the browser uploads directly to R2, keeping bandwidth costs low and upload speeds high.
Create an R2 bucket
- Log in to the Cloudflare dashboard and select your account.
- Go to R2 Object Storage and click Create bucket.
- Give the bucket a name (e.g.
cloudsyncpro). Note the name — it maps toR2_BUCKET_NAMEin your Edge Function secrets. - Leave the default region setting (Cloudflare distributes R2 globally).
Cloudflare R2 has a generous free tier: 10 GB storage, 1 million Class A operations (writes), and 10 million Class B operations (reads) per month. For most early-stage deployments this is more than enough before incurring any charges.
Configure the CORS policy
The browser uploads files directly to R2, so the bucket must allow cross-origin requests from your production domain.In R2 → your bucket → Settings → CORS Policy, add the following configuration:Replace
https://your-domain.com with your actual Vercel deployment URL. During local development you can add http://localhost:5173 as a second entry in AllowedOrigins.Generate R2 API credentials
- In the Cloudflare dashboard go to R2 → Manage R2 API Tokens.
- Click Create API Token.
- Grant Object Read & Write permissions scoped to your bucket.
- Copy the Access Key ID and Secret Access Key — they are shown only once.
- Note your Cloudflare Account ID (visible in the right-hand sidebar of the dashboard).
R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_BUCKET_NAME). See Configure Supabase for details.Set the public bucket URL
The frontend uses
VITE_R2_PUBLIC_URL to construct read URLs for stored files (images, PDFs, etc.). You have two options:Option A — pub.r2.dev (quickest)Enable the public access URL in R2 → your bucket → Settings → Public Access. Cloudflare assigns a URL in the form https://pub-<hash>.r2.dev. Use that as VITE_R2_PUBLIC_URL.Option B — Custom domain (recommended)In R2 → your bucket → Settings → Custom Domains, attach a domain you control (e.g. files.your-domain.com). Then set:How the upload flow works
Understanding the upload flow helps when debugging permissions or CORS errors:- Client requests a presigned URL — the browser calls the
upload-fileSupabase Edge Function, passing the filename, MIME type, workspace ID, and parent folder. - Edge Function validates and signs — the function checks the user’s workspace permissions via the Supabase service role, then generates a time-limited R2 presigned
PUTURL using the R2 API credentials. - Client uploads directly to R2 — the browser
PUTs the file binary straight to the presigned URL. This request goes directly to Cloudflare and never passes through Supabase, saving bandwidth and avoiding the 6 MB Supabase Edge Function body limit. - Client registers the file in Postgres — after a successful
PUT, the browser calls the Supabase API to insert a record into thefilestable with the R2 object key, size, and metadata.
AllowedOrigins in the R2 CORS policy exactly matches the origin your app is served from (including the https:// scheme and no trailing slash).