Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Functions https.onCall finished with status code: 204

Firebase Function

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({ origin: true });

exports.addMessage = functions.https.onCall((data, context) => {
  return { text: "Test" };
});

Issue

The problem is when i call this function from the app i first get finished with status code: 204 and after that finished with status code: 200

204

How can i prevent this?

like image 398
Can Avatar asked Apr 19 '18 23:04

Can


1 Answers

This is normal, and you shouldn't do anything to prevent it. The first request that results in 204 is what happens when CORS performs a preflight request. The 200 is the final serviced request.

You can read more about that here:

Two calls on Post request: with http 204 and 200

like image 140
Doug Stevenson Avatar answered Oct 17 '22 13:10

Doug Stevenson