fix: meeting ended incorrect content type (#12484)

This commit is contained in:
Amit Sharma
2023-11-30 17:52:55 +00:00
committed by GitHub
parent 56050b994d
commit 338756439f
2 changed files with 7 additions and 1 deletions
+6
View File
@@ -5,6 +5,8 @@ import dayjs from "@calcom/dayjs";
import { defaultHandler } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { jsonParse } from "./sendPayload";
async function handler(req: NextApiRequest, res: NextApiResponse) {
const apiKey = req.headers.authorization || req.query.apiKey;
if (process.env.CRON_API_KEY !== apiKey) {
@@ -27,6 +29,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
await fetch(job.subscriberUrl, {
method: "POST",
body: job.payload,
headers: {
"Content-Type":
!job.payload || jsonParse(job.payload) ? "application/json" : "application/x-www-form-urlencoded",
},
});
} catch (error) {
console.log(`Error running webhook trigger (retry count: ${job.retryCount}): ${error}`);
@@ -87,7 +87,7 @@ function applyTemplate(template: string, data: WebhookDataType, contentType: Con
return compiled;
}
function jsonParse(jsonString: string) {
export function jsonParse(jsonString: string) {
try {
return JSON.parse(jsonString);
} catch (e) {