I'm trying to:
- generate on the server side a resumable upload URL using either XML API or JSON API -> URL is generated correct and can be used
- return that URL to browser and force upload of a file to that URL using JavaScript / jQuery.
- When doing the call, since is a CORS request:
a) first a preflight request is sent and get back a response 200, which includes header: access-control-allow-origin with the correct host name
b) next, the upload request is sent to Google storage, upload is done correct and get back the response (e.g including JSON with the upload details).
BUT the response does not include header: access-control-allow-origin and because of that browser complains: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.googleapis.com/upload/storage/v1/b/test-bucket/o?uploadType=resumable&upload_id=AEnB2UoTmA9ul. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
To solve this problem some articles suggest:
- to send as "Origin" header when generating the resumable upload URL the location of the client who will do the real upload. I did that for both JSON API and XML API. But still the same
- to configure bucket to accept CORS requests -> this is my bucket CORS configuration: [{"method": ["PUT", "GET", "OPTIONS"], "origin": ["*"]}]