Getting "missing token ‘authorization’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel" when using spaces

February 4, 2018 5k views
DigitalOcean JavaScript


I’m trying to use the AWS Javascript SDK with spaces but for some reason I’m getting the following error in the Javascript console:

“missing token ‘authorization’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel”

AFAIK, this is an auth error but I thought the AWS SDK handles auth automatically.

Here is my code:

URL = "https://{$REIGON}"

var ep = new AWS.Endpoint(URL);
var s3 = new AWS.S3({
  endpoint: ep,
  accessKeyId: "{$ACCESSKEY}",
  secretAccessKey: "{$SECRETKEY}",

s3.listBuckets({}, function(err, data) {
  if (err) console.log(err, err.stack);
  else console.log(dat);

  { Bucket: "bucket1", Key: "keyvalue" },
  function (error, data) {
    if (error != null) {
      alert("Failed to retrieve object: " + error);
    } else {
      alert("Loaded" + data.ContentLength + " bytes");
Be the first one to answer this question.