This document provides instructions for setting up Firebase Storage for the Ebb Product Board application to properly handle profile images.
First, you need to enable Firebase Storage for your project:
- Go to the Firebase Console
- Select your project: "ebb-roadmap"
- In the left navigation, click on "Storage"
- Click the "Get Started" button
- Choose your storage location (usually the default is fine)
- Accept the default security rules for now (we'll customize them later)
After enabling Firebase Storage in the console, deploy the security rules:
# First make sure you're logged in to Firebase
firebase login
# Deploy the storage rules
firebase deploy --only storageTo enable cross-origin requests to your Firebase Storage bucket:
-
Find your bucket name. It should be in the format:
gs://ebb-roadmap.appspot.com(You can see this in the Firebase Console under Storage) -
Create a CORS configuration file (cors.json):
[
{
"origin": ["http://localhost:5173", "http://localhost:3000", "https://ebb-roadmap.web.app"],
"method": ["GET", "PUT", "POST", "DELETE", "HEAD"],
"maxAgeSeconds": 3600,
"responseHeader": ["Content-Type", "Authorization", "Content-Length", "User-Agent", "x-goog-resumable"]
}
]- Apply the CORS configuration (replace
YOUR_BUCKET_NAMEwith your actual bucket name):
gsutil cors set cors.json gs://YOUR_BUCKET_NAMEAfter setting up Firebase Storage properly, you'll need to restore the original functionality:
-
In
src/services/profileService.ts, uncomment the line:// return await storeProfileImage(user, user.photoURL);And remove the line:
return user.photoURL;
-
In
src/components/ui/ProfileImage.tsx, restore the Firebase Storage URL checking:// First check if we can directly use the photoURL (if it's a Firebase Storage URL) if (user.photoURL && isFirebaseStorageUrl(user.photoURL)) { setImageUrl(user.photoURL); return; }
Once everything is set up:
- Sign out and sign back in to trigger profile image storage
- Check the Firebase Storage console to verify images are being uploaded
- Inspect network requests to ensure CORS is properly configured
For reference, these are the security rules we're using:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Profile images can be uploaded by authenticated users and read by anyone
match /profile_images/{userId}/{fileName} {
// Only allow uploads if the user is authenticated and the file is for their own profile
allow write: if request.auth != null &&
request.auth.uid == userId;
// Anyone can read profile images
allow read: if true;
}
// Default deny rule
match /{allPaths=**} {
allow read, write: if false;
}
}
}