Skip to content

Commit dfa03b7

Browse files
committed
fix(webhooks): standardize rawBody types and signature verification
1 parent ca1f83f commit dfa03b7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

apps/server/src/routes/webhooks.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { broadcastToUsers } from '@/ws/handler';
2424

2525
/** Extended request with raw body for signature verification. */
2626
interface RawBodyRequest extends FastifyRequest {
27-
rawBody?: Buffer;
27+
rawBody?: string | Buffer;
2828
}
2929

3030
/** Zod schema for GitHub Issues webhook payload. */
@@ -136,7 +136,10 @@ export function webhookRoutes(app: FastifyInstance): void {
136136
error: 'Raw body required for signature verification. Server misconfiguration.',
137137
});
138138
}
139-
const rawBody = rawRequest.rawBody;
139+
const rawBody =
140+
typeof rawRequest.rawBody === 'string'
141+
? Buffer.from(rawRequest.rawBody)
142+
: rawRequest.rawBody;
140143

141144
const signature = getHeader(request, 'x-hub-signature-256');
142145
const event = getHeader(request, 'x-github-event');

0 commit comments

Comments
 (0)