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

查看:27
本文介绍了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

如何防止这种情况发生?

How can i prevent this?

推荐答案

这是正常的,你不应该采取任何措施来阻止它.导致 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天全站免登陆