Firebase cors config

I’m trying to configure the rules for firebase storage.

mainly to add access for appgyver preview.

this is the current script version:

rules_version = ‘2’;
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;

  // Add CORS configuration for web access
  allow origin: if request.method == "OPTIONS" || request.method == "GET" 
               || request.method == "HEAD" 
               || request.method == "POST" 
               && request.headers.origin == "https://preview.appgyver.com";
}

// Add access for iOS and Android app stores
match /{allPaths=**} {
  allow read: if request.auth == null && request.resource.contentType.matches('image/.*');
}

}
}

Can some one help me fix this, also help if I’m missing anything, etc. I’m not familiar at all with doing this. Thank you

Which documentation did you follow for these rules? :point_up_2:

Have you looked at this: Configure CORS for web - tutorial

Hey Fred,

I’m following this Firebase - Google Firebase

This is not helpful at all for a beginner.

Used chatgpt to write the script, since I’m not familiar with it