Have anyone connected Firebase Storage? To an app? I’m getting the CORS problem…
to a web app yes. Do you mean to an iOS or Android native app? gonna need some more info.
on the web app created with firebase studio ai.
Yes. I’m just going through the process on my 2nd app creation at the moment. You will need to create a Firestore database using the Firebase Console. Then you will need to run a few terminal commands in Studio and then add a few lines to your firebase config. Asking the version of Gemini in the Firebase Console is a good way to get some advice on what to do.
Can you provide instructions on how you got it to work in local firebase dev env?
I’ve only ever done it using actual storage rather than emulating it in a local dev environment.
Did you try creating authenticated user in firebase console → Project Overview → Users and permissions
Then use the UID for firestore rules
rules_version = ‘2’;
service cloud.firestore {
match /databases/{database}/documents {
// Replace this with your admin UID
function isAdmin() {
return request.auth != null && request.auth.uid == “UID***”;
}
match /{document=**} {
allow read, write: if isAdmin();
}
}
}
I found the solution:
- Open the GCP console and start a cloud terminal session by clicking the
>_
icon button in the top navbar. Or search for “cloud shell editor” in the search bar. - Click the pencil icon to open the editor, then create the
cors.json
file. - Run
gsutil cors set cors.json gs://your-bucket
the content of cors.json
[
{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
For additional security, you can limit your origins.
Right now your origin is set to a wildcard which is open to all. Maybe it works for your use case though.
That’s a good observation! Thanks for the reminder.