Configure cross-origin resource sharing (CORS)
Cross Origin Resource Sharing (CORS) allows interactions between resources fromdifferent origins, something that is normally prohibited in order to preventmalicious behavior. This page explains how to configure CORS on aCloud Storage bucket for a sample origin, the origin of the onlineShaka media player.
Note: Enabling cross-origin resource sharing is not necessary to use the Transcoder API, butyou can use this guide to set up storage buckets so that you can review content from web-basedplayers.Toenable cross-origin resourcesharing (CORS) on a Cloud Storage bucket, do the following:- Create a JSON file that contains the following:
[ { "origin": ["https://shaka-player-demo.appspot.com/"], "responseHeader": ["Content-Type", "Range"], "method": ["GET", "HEAD"], "maxAgeSeconds": 3600 }] - Run the following command after replacingJSON_FILE_NAME with the name of the JSON file you created in the previous step:
gcloud storage buckets update gs://STORAGE_BUCKET_NAME --cors-file=JSON_FILE_NAME.json
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-24 UTC.