Skip to content

Bucket CORS rules

CORS rules decide which websites may use a bucket’s files from a browser. Open them with Connection Actions → CORS Rules… while the remote pane is inside the bucket (on a connection to a single bucket, anywhere). See S3 connection actions and buckets for when the row is live.

The sheet is titled “CORS rules for “…”” with the bucket’s name. It reads the bucket’s current rules first. A bucket with none says so: “This bucket has no CORS rules yet. Add one to let a website use its files.”

Fields and text: two views of the same rules

Section titled “Fields and text: two views of the same rules”

A choice labelled Show rules as switches between two views of one set of rules. Whatever you change in one is there in the other.

ViewWhat it is for
FieldsOne card per rule — Rule 1, Rule 2, … — with a form for each setting. The sheet opens on this view.
TextThe same rules written out as text, in the form the storage service itself uses. Edit it directly to paste a configuration in, or to say something the fields cannot.
FieldMeaning
Name (optional)A label for the rule.
Allowed originsThe websites the rule applies to. * allows any website. Use Add and Remove for more than one.
Allowed methodsA checkbox each for GET, PUT, POST, DELETE and HEAD.
Allowed headersRequest headers the rule permits. Optional.
Exposed headersResponse headers the browser may read. Optional.
Cache the answer for (seconds)How long a browser may remember the answer. A whole number of seconds, or empty.

Add Rule appends a rule that starts with GET ticked and an empty origin; Remove Rule deletes one.

Text can say things a rule has no place for. The fields never pretend otherwise, and they never drop what they cannot show. When the text holds one of these, the Fields view is switched off, the sheet shows the text, and a grey sentence says why:

  • the text is not a readable CORS configuration (yet);
  • it holds an element the fields have no place for;
  • it allows a method other than GET, PUT, POST, DELETE or HEAD;
  • a value in a rule runs over more than one line, which a field cannot hold.

Text that is unreadable, that holds an element the fields have no place for, or that allows another method is not saved as it is. Fix or remove the part in the text and the fields come back.

Save is live only when the rules differ from what the bucket has and nothing below stops it. Two things are checked before anything is sent:

  • Every rule needs at least one allowed origin and at least one allowed method. The sheet names the rule: “Rule 2 needs at least one allowed origin.”
  • The text must be a readable CORS configuration whose values would be saved exactly as you see them. Otherwise: “The text is not a readable CORS configuration yet, so it cannot be saved.” or “Saving would change a value in the text, so it cannot be saved as it is.”

After a successful save the sheet reads the rules back from the bucket, so what you see is what the bucket now has.

Saving without any rules removes the bucket’s CORS configuration altogether. The sheet tells you before you press the button: “Saving without any rules removes this bucket’s CORS configuration.” That is the way to switch CORS off for a bucket.

  • “The CORS rules of this bucket could not be read.” or “…could not be saved.” — the request failed. The sheet says so in red.
  • “Your access key is not allowed to read or change the CORS rules of this bucket.” — the access key lacks the permission.

Every save, including a refused one, is written to the audit log as CORS rules changed. The entry gives the number of rules saved, or that the configuration was cleared, not their contents.