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

廉价感情. 提交于 2019-12-21 04:15:14

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/49931587/firebase-cloud-functions-https-oncall-finished-with-status-code-204

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!