nextjs-gcp-storage icon indicating copy to clipboard operation
nextjs-gcp-storage copied to clipboard

Cross-Origin Request Blocked:

Open damiano216 opened this issue 3 years ago • 1 comments

Hello,

Using the code provided and the instructions, I tried to upload a file to my bucket, but in the dev console got the error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://storage.googleapis.com/my-bucket-name-here/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 400.

Could you please advise on how to solve this? Thanks in advance!

damiano216 avatar Oct 20 '22 10:10 damiano216

@damiano216 Please provide information that logged out of this command:

gcloud storage buckets describe gs://BUCKET_NAME --format="default(cors)"

The CORS is misconfigured if the above command returns a null or nothing. The expected result from this command is something like this:

cors:
- maxAgeSeconds: 3600
  method:
  - POST
  - DELETE
  origin:
  - '*'
  responseHeader:
  - '*'

ImBIOS avatar Dec 07 '22 14:12 ImBIOS