Configurazione della condivisione delle risorse tra origini (CORS)
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
La condivisione delle risorse tra origini (CORS) consente le interazioni tra risorse provenienti da origini diverse, un'operazione normalmente vietata per prevenire comportamenti dannosi. Questa pagina spiega come configurare CORS su un
bucket Cloud Storage per un'origine di esempio, l'origine del media player online
Shaka.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Configure cross-origin resource sharing (CORS)\n\nCross Origin Resource Sharing (CORS) allows interactions between resources from\ndifferent origins, something that is normally prohibited in order to prevent\nmalicious behavior. This page explains how to configure CORS on a\nCloud Storage bucket for a sample origin, the origin of the online\n[Shaka](https://shaka-player-demo.appspot.com/demo/) media player.\n| **Note:** Enabling cross-origin resource sharing is not necessary to use the Transcoder API, but you can use this guide to set up storage buckets so that you can review content from web-based players.\nTo [enable cross-origin resource\nsharing (CORS) on a Cloud Storage bucket](/storage/docs/using-cors#configure-cors-bucket), do the following:\n\n1. Create a JSON file that contains the following: \n\n ```\n [\n {\n \"origin\": [\"https://shaka-player-demo.appspot.com/\"],\n \"responseHeader\": [\"Content-Type\", \"Range\"],\n \"method\": [\"GET\", \"HEAD\"],\n \"maxAgeSeconds\": 3600\n }\n ]\n ```\n2. Run the following command after replacing \u003cvar translate=\"no\"\u003eJSON_FILE_NAME\u003c/var\u003e with the name of the JSON file you created in the previous step: \n\n ```\n gcloud storage buckets update gs://STORAGE_BUCKET_NAME --cors-file=JSON_FILE_NAME.json\n ```"]]