Reputation: 243
I have tried two techniques to try to enable CORS on my firebase storage bucket, but so far none of them have worked. I get this error... Access to Image at 'location' from origin 'server' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
First I tried using gsutil following this example. The terminal says it sets the data for my, "Setting CORS on gs://"my-app's-name".appspot.com/..." however I still get the error on the front end.
Next I tried using Firebase Cloud Functions within my Angular 5 app following this example. I wasn't able to find a way to set this globally, and even with an image I still got the same error on the front end.
I have spent a while trying to enable CORS now, it seems like it should be fairly trivial, but I'm relatively new to cloud functions. I'd prefer the gsutil method. Gonna keep hitting my head against this problem, will post a solution if I find it.
Thank you, any help is appreciated.
Upvotes: 2
Views: 4454
Reputation: 243
I got it working! I was trying the gsutil method once more, taking a slightly different approach. Following @Andrew McOlash in THIS post. The two differences between the gsutil method I tried before and the one that worked were.
File name: (FROM) cors-test-json.json ~>(TO) cors.json
File: (FROM)
[
{
"origin": ["<my domain>"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
(TO)
[
{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
Upvotes: 6