Skip to content

Commit

Permalink
move check within handler
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Oct 9, 2024
1 parent eda7513 commit b1323bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/webservice/src/app/api/github/webhook/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { env } from "~/env";
import { handleCommitWebhookEvent } from "./commit/handler";
import { handleWorkflowWebhookEvent } from "./workflow/handler";

const secret = env.GITHUB_WEBHOOK_SECRET;
if (secret == null) throw new Error("GITHUB_WEBHOOK_SECRET is not set");
const webhooks = new Webhooks({ secret });

export const POST = async (req: NextRequest) => {
try {
const secret = env.GITHUB_WEBHOOK_SECRET;
if (secret == null) throw new Error("GITHUB_WEBHOOK_SECRET is not set");
const webhooks = new Webhooks({ secret });

const signature = req.headers.get("x-hub-signature-256")?.toString();
if (signature == null)
return new NextResponse("No signature", { status: 401 });
Expand Down

0 comments on commit b1323bd

Please sign in to comment.