CORS error on file upload

21 views
Skip to first unread message

Sumit Kumar

unread,
Jun 10, 2021, 11:10:43 AMJun 10
to google-cloud-storage-discuss
Hi,
I am new to cloud-storage.

I am using fetch on client side to upload an image file using signed request.
const uploadResponse = await fetch(response.signedURL, { method: 'PUT', mode: 'cors', body: selectedFile, credentials: 'omit', headers: { 'Access-Control-Allow-Origin':'*' } });

Configured my storage bucket 'recoverlution-dev'  using following config

[ { "origin": ["https://zipsym.eu.loclx.io"], "responseHeader": ["Content-Type","Access-Control-Allow-Origin"], "method": ["PUT"], "maxAgeSeconds": 3600 } ]

with this gsutils command
gsutil cors set cors-json-file.json gs://recoverlution-dev

But still I am getting the following error https://i.stack.imgur.com/AwSX5.png

These are my response headers https://i.stack.imgur.com/WWJVT.png

Can anyone tell me what am I doing wrong?


gsuceveanu

unread,
Jun 10, 2021, 4:09:28 PMJun 10
to google-cloud-storage-discuss
Hello Sumit, 

You may find valuable information on the very same error in a reply to the "No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API" question in stackoverflow. 

This discussion group is oriented more towards general opinions, trends, and issues of general nature touching the App Engine. For coding and program architecture, as well as CORS-related errors, you may be better served in dedicated forums such as stackoverflow, where experienced programmers are within reach and ready to help. 

Sumit Kumar

unread,
Jun 11, 2021, 2:17:46 AMJun 11
to google-cloud-storage-discuss
Thanks for your time. I raised the issue just to know is there any bug related to CORS or I need some additional configurations in google-cloud-storage.

wushawn

unread,
Jun 14, 2021, 11:34:24 AMJun 14
to google-cloud-storage-discuss
Based on the information in the screenshot, I have checked the bugs. There seems to be  working as expected behavior that is to say there is no bug currently could effects on the CORS services. you can refer to Configuring cross-origin resource sharing (CORS)(https://cloud.google.com/storage/docs/configuring-cors) for details.
Reply all
Reply to author
Forward
0 new messages