From 5895bb7ba06d9d762e5882561e6dc6362ef5e271 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sun, 30 Jul 2023 00:18:32 +0200 Subject: [PATCH] Added content-type check --- examples/firebase/functions/src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/firebase/functions/src/index.ts b/examples/firebase/functions/src/index.ts index e588c78..65d259f 100644 --- a/examples/firebase/functions/src/index.ts +++ b/examples/firebase/functions/src/index.ts @@ -58,6 +58,14 @@ declare global { export const pass = functions.https.onRequest( async (request: RequestWithBody, response) => { + if (request.headers["content-type"] !== "application/json") { + response.status(400); + response.send({ + error: `Payload with content-type ${request.headers["content-type"]} is not supported. Use "application/json"`, + }); + return; + } + if (!request.body.passModel) { response.status(400); response.send({