diff --git a/javascript/src/index.ts b/javascript/src/index.ts index 6b93adddc..69f5213a8 100644 --- a/javascript/src/index.ts +++ b/javascript/src/index.ts @@ -768,6 +768,10 @@ export class Webhook { | WebhookUnbrandedRequiredHeaders | Record ): unknown { + if (typeof payload !== "string") { + throw new Error("Expected payload to be of type string. Please refer to https://docs.svix.com/receiving/verifying-payloads/how for more information."); + } + const headers: Record = {}; for (const key of Object.keys(headers_)) { headers[key.toLowerCase()] = (headers_ as Record)[key];