title: Firestore - function works in development mode but does not work in production
body: <p>I am trying to figure out how to setup a react firebase web app.</p>
  
  <p>I have a firebase.js config file with all of the methods below. The helper that runs the register method is included in this file as:</p>
  
  <pre><code>async register({email, password, name, beta, roleNominated}) {
            await this.auth.createUserWithEmailAndPassword(email, password);
            await this.auth.currentUser.updateProfile({
              displayName: name,
            })
            const uid = this.auth.currentUser.uid;
            await 
              this.firestore.collection("users").doc(uid).set({ 
              role: 'PENDING',
              createdAt: app.firestore.FieldValue.serverTimestamp(),
  </code></pre>
  
  <p>The whole file is:</p>
  
  <pre><code>import app from 'firebase/app';
  import 'firebase/auth';
  import 'firebase/firestore';
  // import 'firebase/storage';
  
  
  const devConfig = {
    apiKey: process.env.REACT_APP_DEV_API_KEY,
    authDomain: process.env.REACT_APP_DEV_AUTH_DOMAIN,
    databaseURL: process.env.REACT_APP_DEV_DATABASE_URL,
    projectId: process.env.REACT_APP_DEV_PROJECT_ID,
    storageBucket: process.env.REACT_APP_DEV_STORAGE_BUCKET,
    messagingSenderId: process.env.REACT_APP_DEV_MESSAGING_SENDER_ID,
    appId: process.env.REACT_APP_DEV_APP_ID
  
  };
  
  
  const prodConfig = {
    apiKey: process.env.REACT_APP_PROD_API_KEY,
    authDomain: process.env.REACT_APP_PROD_AUTH_DOMAIN,
    databaseURL: process.env.REACT_APP_PROD_DATABASE_URL,
    projectId: process.env.REACT_APP_PROD_PROJECT_ID,
    storageBucket: process.env.REACT_APP_PROD_STORAGE_BUCKET,
    messagingSenderId: process.env.REACT_APP_PROD_MESSAGING_SENDER_ID,
    appId: process.env.REACT_APP_PROD_APP_ID
  };
  
  
  const config =
    process.env.NODE_ENV === 'production' ? prodConfig : devConfig;
  
  
  
  
  
  class Firebase {
    constructor() {
      app.initializeApp(config)
      this.firestore = app.firestore();
      this.auth = app.auth();
  
    }
  
    // helper functions for authentication and user management
    async register({email, password, name, beta, roleNominated}) {
        await this.auth.createUserWithEmailAndPassword(email, password);
        await this.auth.currentUser.updateProfile({
          displayName: name,
        })
        const uid = this.auth.currentUser.uid;
        await 
          this.firestore.collection("users").doc(uid).set({ 
          role: 'PENDING',
          createdAt: app.firestore.FieldValue.serverTimestamp(),
        });
        await this.auth.currentUser.sendEmailVerification();
    }
  
    login(email, password) {
      return this.auth.signInWithEmailAndPassword(email, password)
    };
  
    logout() {
      return this.auth.signOut();
    }
  
    getUser() {
      return  this.auth.currentUser();
    }
  
    authChange(user) {
        return this.auth.onAuthStateChanged(user);
    }
  
    sendEmailVerification = () =&gt;
        this.getUser.sendEmailVerification({
        // url: process.env.REACT_APP_CONFIRMATION_EMAIL_REDIRECT
        url: process.env.NODE_ENV === 'production' ? process.env.REACT_APP_PROD_CONFIRMATION_EMAIL_REDIRECT : process.env.REACT_APP_DEV_CONFIRMATION_EMAIL_REDIRECT,
      });
  
  };
  
  export default new Firebase();
  </code></pre>
  
  <p>I have a signup form with:</p>
  
  <pre><code>import import Firebase from '../../../../firebase.js';
  </code></pre>
  
  <p>then, register is called in the onCreate:</p>
  
  <pre><code>const onCreate = async values =&gt; {
      try {
          await Firebase.register(values)
      } catch(err){
          console.error(err);
      }    
      setVisible(false);
    };
  </code></pre>
  
  <p>register is imported from the firebase.js file.</p>
  
  <p>When I run this in my local environment - I successfully authenticate a user in the firebase auth module and create a user document in the users collection with the values I've asked for in the register method.</p>
  
  <p>When I deploy this to the production environment, the auth step succeeds but errors are generated when it tries to make a document in the users collection. The error message says:</p>
  
  <blockquote>
    <p>TypeError: this.firestore.collection(...).set is not a function</p>
  </blockquote>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/54998402/condition-fails-in-react-native-production-but-works-in-development">this post</a> which also has a problem deploying code that works in development, but fails in firebase production. That particular issue seems to be related to how dates are used in ES6.</p>
  
  <p>I have the same security rules in both production and development projects and both have:</p>
  
  <pre><code>match /users/{userId} {
        allow read;
        allow write;
      }
  </code></pre>
  
  <p>Is there any advice for how to figure out what is preventing the firestore user collection from creating a document in the production environment?</p>