I\'m trying to get files via AJAX from google cloud storage on my local host. I have done the following:
Set the CORS for my bucket via gsutil:
gsutil
You're using "googleapis.com" instead of "www.googleapis.com". Add the "www" and your code will work.
It looks like you're not doing any authentication, so you'll also need to make sure that your bucket allows anonymous users to list objects (gsutil acl ch -g allUsers:R gs://bucket-name
will set that).
Next, for anonymous requests, it's a good practice to add an API key parameter associating the request with your Google Cloud project. GCS will allow completely anonymous requests, but they may be blocked if they get too frequent.
Finally, the CORS policy on a bucket is only respected by the XML API. The JSON API, which is the one with the endpoint of "www.googleapis.com", will happily respond to cross-origin requests without the need to set any special properties on the bucket.