Skip to content

Scheduling infrastructure for absolutely everyone.

fix: meeting ended incorrect content type (#12484)

Amit Sharma338756439fe3
diff --git a/packages/features/webhooks/lib/cron.ts b/packages/features/webhooks/lib/cron.ts
index 089ddbbc5a8..913217b2741 100644
--- a/packages/features/webhooks/lib/cron.ts
+++ b/packages/features/webhooks/lib/cron.ts
@@ -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}`);
diff --git a/packages/features/webhooks/lib/sendPayload.ts b/packages/features/webhooks/lib/sendPayload.ts
index 7ff22d95776..dc6e76f1d2a 100644
--- a/packages/features/webhooks/lib/sendPayload.ts
+++ b/packages/features/webhooks/lib/sendPayload.ts
@@ -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) {