title: Prevent Firebase functions being invoked twice due to preflight request
body: <p>I have a javascript web application written in React which is using the Firebase SDK to make calls to my Firebase Cloud Functions written in Node 8. For simplicity, the code looks like this:</p>
  
  <p><strong>API index.js</strong></p>
  
  <pre><code>module.exports.test = functions.https.onCall((data, context) =&gt; {
     return 'Finished'
  })
  </code></pre>
  
  <p><strong>React code</strong></p>
  
  <pre><code>app.functions().httpsCallable('test')().then(console.log)
  </code></pre>
  
  <p>The code itself works great, however when looking at the logs, I can see 2 invocations.</p>
  
  <p><a href="https://i.stack.imgur.com/GCfO6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GCfO6.png" alt="Function call 1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/4uiFN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4uiFN.png" alt="Function call 2"></a></p>
  
  <p>This seems to be from the CORS preflight request the browser is making before making the actual call. </p>
  
  <p>Am I charged for this preflight request invocation, and how can I prevent it (if at all)? Are there any headers or settings I can add either client or function side to ensure that my function invocation quota is essentially halved?</p>