Uploading straight to your bucket, and the CORS rule it needs
2 min read
Uploading a file through an admin panel sounds simple until you think about where the bytes go. If they pass through the panel's server, that server needs to accept large requests, hold the file and forward it, and it sees every file your team uploads. We didn't want any of that, so in Baseboard the file goes from your browser straight to your store.
That choice has one cost, and it trips people up: CORS.
How the upload works
When you pick Upload on a bucket's Files page, Baseboard asks your store for a short-lived upload
for each file, valid for about fifteen minutes, and hands it to your browser. The browser sends
the file there itself. What Baseboard asks for depends on the store: a presigned PUT link for
S3 and S3-compatible stores like R2, B2 and Tigris, a resumable session for Google Cloud Storage,
a signed upload link for Supabase, and so on.
Files upload one at a time. If one fails, the upload stops there and tells you how many went through, so you know exactly which file to retry.
Why the browser refuses
A browser only sends a request to another site if that site says it accepts requests from the page making it. That's CORS. A brand new S3 or R2 bucket says no to everyone, so the first upload fails before the store sees it.
Baseboard catches this case and tells you what to allow: "The store didn't accept the upload from this site", followed by the method and the exact address to add.
The rule to add
For S3, R2 and most S3-compatible stores, the rule is short:
[
{
"AllowedOrigins": ["https://your-baseboard-address"],
"AllowedMethods": ["PUT"],
"AllowedHeaders": ["Content-Type"],
"MaxAgeSeconds": 3600
}
]
Google Cloud Storage and Firebase take the same idea in their own format. Supabase Storage, Convex, Vercel Blob and UploadThing allow browser uploads already, so they need nothing.
Two things catch people out. The origin has to match exactly: https, no trailing slash, no path.
And rules can take a minute to apply, so a retry straight after saving may still fail.
Who can upload
Uploading changes data, so it's off for every member until an owner allows Upload object for them, and it needs a paid plan. The storage uploads guide has the rule for each store and what each error means.