我正在尝试处理 Firebase 函数中的无效请求,因此使用无效的 JSON 发出发布请求,目的是在 Express 中处理它。但在到达 Express 层之前,我收到了400 错误“SyntaxError: Unexpected token a in JSON atposition 20”,最糟糕的是该函数运行了 60 秒,直到遇到超时错误。
我的职能
import * as functions from 'firebase-functions';
import * as express from 'express';
import * as admin from 'firebase-admin';
admin.initializeApp();
const app = express();
app.use((err: any, req: any, res: any, next: any) => {
  res.json({ error: 'invalid request' });
  next(err);
});
app.post('/test', (req: any, res: any) => {
  res.json({ error: 'invalid request' });
  res.end();
  return;
});
const server = …Run Code Online (Sandbox Code Playgroud)