Skip to content

Commit 2ea0c34

Browse files
authored
Bugfix for newly hosted webhook handler. (#68)
1 parent 3c6c1b9 commit 2ea0c34

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

backend/src/api/apiResponseHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default class ApiResponseHandler {
1515
}
1616

1717
static async error(_req, res, error) {
18+
console.log('API ERROR', error)
19+
1820
if (error && [400, 401, 403, 404].includes(error.code)) {
1921
res.status(error.code).send(error.message)
2022
} else {

backend/src/serverless/integrations/webhooks/github.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,10 @@ export default class GitHubWebhook {
491491
try {
492492
const signature = req.headers['x-hub-signature']
493493
const secret = GITHUB_CONFIG.webhookSecret
494+
494495
console.log('Verifying webhook...')
495-
const isVerified = verifyGithubWebhook(signature, req.body, secret) // Returns true if verification succeeds; otherwise, false.
496+
const isVerified = verifyGithubWebhook(signature, JSON.stringify(req.body), secret) // Returns true if verification succeeds; otherwise, false.
497+
496498
console.log('Verification', isVerified)
497499
if (!isVerified) {
498500
throw new Error('Webhook not verified')

backend/src/serverless/integrations/workers/githubWebhookWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import GitHubWebhook from '../webhooks/github'
22

33
export default async function githubWebhookWorker(req) {
44
GitHubWebhook.verify(req)
5-
const result = await new GitHubWebhook(req.headers['x-github-event'], JSON.parse(req.body)).main()
5+
const result = await new GitHubWebhook(req.headers['x-github-event'], req.body).main()
66
return result
77
}

0 commit comments

Comments
 (0)