2016-06-11 12 views
24

Firewall'lardan bir XMLHttpRequest aracılığıyla dosyaları karşıdan yüklemeyi deniyorum, ancak Access-Control-Allow-Origin kaynağında ayarlanmadı, bu yüzden mümkün değil. Bu üstbilgiyi depolama sunucusuna yerleştirmenin herhangi bir yolu var mı?Firebase Depolama Alanı ve Erişim Denetimi-İzin-Menşei

(let [xhr (js/XMLHttpRequest.)] 
    (.open xhr "GET" url) 
    (aset xhr "responseType" "arraybuffer") 
    (aset xhr "onload" #(js/console.log "bin" (.-response xhr))) 
    (.send xhr))) 

Krom hata iletisi: Bu post on the firebase-talk group/list itibaren

XMLHttpRequest cannot load https://firebasestorage.googleapis.com/[EDITED] No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:3449 ' is therefore not allowed access.

+1

yeterli temsilcisi, ancak yukarıdaki yolu hala doğru yoldur. Bunun için resmi firebase dokümanlarını paylaşmak istedim: https://firebase.google.com/docs/storage/web/download-files#cors_configuration –

cevap

48

: açıklama için

The easiest way to configure your data for CORS is with the gsutil command line tool. The installation instructions for gsutil are available at https://cloud.google.com/storage/docs/gsutil_install . Once you've installed gsutil and authenticated with it, you can use it to configure CORS.

For example, if you just want to allow object downloads from your custom domain, put this data in a file named cors.json (replacing "https://example.com" with your domain):

[ 
    { 
    "origin": ["https://example.com"], 
    "method": ["GET"], 
    "maxAgeSeconds": 3600 
    } 
] 

Then, run this command (replacing "exampleproject.appspot.com" with the name of your bucket):

gsutil cors set cors.json gs://exampleproject.appspot.com 

and you should be set.

If you need a more complicated CORS configuration, check out the docs at https://cloud.google.com/storage/docs/cross-origin#Configuring-CORS-on-a-Bucket .

+2

Tüm kaynakların Erişim Denetimi'ne izin vermesine benzer bir yol var mı? Menşei: * ? – user1311069

+2

Firebase bucket'ımın tam adını nasıl bulabilirim? – Jim

+0

cors.json'u nerede bulabilirim? – isuru

İlgili konular