firebase云函数模拟器中缺少rawBody

firebase云函数模拟器中缺少rawBody,firebase,google-cloud-functions,firebase-cli,Firebase,Google Cloud Functions,Firebase Cli,指示req上应存在rawBody参数。但是,在我的本地仿真器中,它是未定义的 我做错了什么? $ firebase --version 7.8.1 用于发布二进制数据的客户端javascript代码: var buffer = new ArrayBuffer(4); var view = new DataView(buffer); function writeUTFBytes(view, offset, string) { var lng = string.length; f

指示
req
上应存在
rawBody
参数。但是,在我的本地仿真器中,它是未定义的

我做错了什么?

$ firebase --version
7.8.1
用于发布二进制数据的客户端javascript代码:

var buffer = new ArrayBuffer(4);
var view = new DataView(buffer);

function writeUTFBytes(view, offset, string) {
    var lng = string.length;
    for (var i = 0; i < lng; i++) {
        view.setUint8(offset + i, string.charCodeAt(i));
    }
}

writeUTFBytes(view, 0, 'RIFF');

var blob = new Blob([view]);

fetch('http://localhost:5001/firebase-project-name/us-central1/endpointName', {
  method: 'POST',
  body: blob
})
当我运行该函数时,我得到如下结果:

$ firebase emulators:start --only functions
<snip>
i  functions: Beginning execution of "endpointName"
>  
>  undefined
$firebase模拟器:仅启动函数
i函数:开始执行“endpointName”
>  
>未定义
我已通过HTTP Toolkit确认,正文实际上是从我的浏览器发送的:


我发现,如果我将内容类型设置为application/octet stream或audio/wave,那么rawBody会突然出现

  fetch(url, {
    method: 'POST',
    headers: new Headers({
      'Content-Type': 'audio/wav',
    }),
    body: blob
  })
然而!我必须修改我的函数以使选项HTTP请求成功,以便我的浏览器询问是否可以包含内容类型标题,否则,实际请求从未发送:

  res.set('Access-Control-Allow-Origin', 'http://localhost:3000');

  if (req.method === 'OPTIONS') {
      // Send response to OPTIONS requests
      res.set('Access-Control-Allow-Methods', 'OPTIONS, POST');
      res.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length');
      res.set('Access-Control-Max-Age', '3600');
      return res.status(204).send('');
  }

然而,我仍然很好奇,为什么没有内容类型头的rawBody就不会出现。至少,可能有一些文档介绍了发送二进制数据和使用rawBody的端到端示例。

请在firebase tools GitHub上提交错误报告@Dough Stevenson好的,贴在这里
  res.set('Access-Control-Allow-Origin', 'http://localhost:3000');

  if (req.method === 'OPTIONS') {
      // Send response to OPTIONS requests
      res.set('Access-Control-Allow-Methods', 'OPTIONS, POST');
      res.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length');
      res.set('Access-Control-Max-Age', '3600');
      return res.status(204).send('');
  }