Firebase Storage and Access-Control-Allow-Origin -
i'm trying download files firebase storage through xmlhttprequest, access-control-allow-origin not set on resource, it's not possible. there way set header on storage server?
(let [xhr (js/xmlhttprequest.)] (.open xhr "get" url) (aset xhr "responsetype" "arraybuffer") (aset xhr "onload" #(js/console.log "bin" (.-response xhr))) (.send xhr)))
chrome error message:
xmlhttprequest cannot load https://firebasestorage.googleapis.com/[edited] no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:3449' therefore not allowed access.
from post on firebase-talk group/list:
the easiest way configure data cors
gsutil
command line tool. installation instructionsgsutil
available @ https://cloud.google.com/storage/docs/gsutil_install. once you've installedgsutil
, authenticated it, can use configure cors.for example, if want allow object downloads custom domain, put data in file named cors.json (replacing
"https://example.com"
domain):[ { "origin": ["https://example.com"], "method": ["get"], "maxageseconds": 3600 } ]
then, run command (replacing
"exampleproject.appspot.com"
name of bucket):gsutil cors set cors.json gs://exampleproject.appspot.com
and should set.
if need more complicated cors configuration, check out docs @ https://cloud.google.com/storage/docs/cross-origin#configuring-cors-on-a-bucket.
Comments
Post a Comment