title: Read/Write Error with Cloud Firestore: The 'Access-Control-Allow-Origin' header has a value 'null'
body: <p>I have a Javascript Web application. I trying to read or write to the Cloud Firestore database but it returns this error in the browser console.</p>
  
  <p><strong>THE ERROR:</strong></p>
  
  <blockquote>
    <p>Failed to load <a href="https://firestore.googleapis.com/google.firestore.v1beta1.Firestore/Write/channel?VER=8&amp;RID=21505&amp;CVER=21&amp;X-HTTP-Session-Id=gsessionid&amp;%24httpHeaders=X-Goog-Api-Client%3Agl-js%2F%20fire%2F4.8.2%0D%0Agoogle-cloud-resource-prefix%3Aprojects%2FProjectName%2Fdatabases%2F(default)%0D%0A&amp;zx=v9xcdtq156tr&amp;t=1" rel="nofollow noreferrer">https://firestore.googleapis.com/google.firestore.v1beta1.Firestore/Write/channel?VER=8&amp;RID=21505&amp;CVER=21&amp;X-HTTP-Session-Id=gsessionid&amp;%24httpHeaders=X-Goog-Api-Client%3Agl-js%2F%20fire%2F4.8.2%0D%0Agoogle-cloud-resource-prefix%3Aprojects%2FProjectName%2Fdatabases%2F(default)%0D%0A&amp;zx=v9xcdtq156tr&amp;t=1</a>:<br>
        The 'Access-Control-Allow-Origin' header has a value 'null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.</p>
  </blockquote>
  
  <p>The Security Rules were set to <strong>Public read/write</strong></p>
  
  <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
     match /{document=**} {
       allow read, write;
     }
   }
  }
  </code></pre>
  
  <p>Here is my test code</p>
  
  <pre><code>&lt;script src="https://www.gstatic.com/firebasejs/4.11.0/firebase.js"&gt;&lt;/script&gt;
  &lt;script src="https://www.gstatic.com/firebasejs/4.11.0/firebase-firestore.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    var config = {
      apiKey: "XXXXXXXXXXX",
      authDomain: "XXXXXXXXXXXX",
      databaseURL: "XXXXXXXXXXXX",
      projectId: "XXXXXXXXXXXX",
      storageBucket: "XXXXXXXXXXXX",
      messagingSenderId: "XXXXXXXXXXXX"
    };
    firebase.initializeApp(config);
  
    // Firebase Variables
    var db = firebase.firestore();
  
    db.collection("cities").doc("LA").set({
      name: "Los Angeles",
      state: "CA",
      country: "USA"
    }).then(function () {
      console.log("Document successfully written!");
    }).catch(function (error) {
      console.error("Error writing document: ", error);
    });
  &lt;/script&gt;
  </code></pre>