Firebase Cloud Functions https.onCall完成,状态码:204 [英] Firebase Cloud Functions https.onCall finished with status code: 204

查看:92
本文介绍了Firebase Cloud Functions https.onCall完成,状态码:204的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase函数

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" };
});

问题

问题是,当我从应用程序调用此函数时,我首先获得状态码:204 ,然后完成状态码:200

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

我该如何预防?

推荐答案

这是正常现象,您不应采取任何措施防止它。导致204的第一个请求是CORS执行预检请求。 200是最终服务请求。

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:

对Post请求的两次调用:http 204和200

这篇关于Firebase Cloud Functions https.onCall完成,状态码:204的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆