Validate hookdeck webhooks

This commit is contained in:
2025-06-02 12:05:41 +03:00
parent 0cd5c6cb69
commit 80fe63b82e
6 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import type { H3Event } from "h3";
import { isEmpty } from "radash";
export const validateHookdeck = async (event: H3Event) => {
const hookdeckKeyHeader = getHeader(event, "X-Hookdeck-Key");
const config = useRuntimeConfig();
if (isEmpty(hookdeckKeyHeader)) {
throw createError({
status: 401,
});
}
if (hookdeckKeyHeader !== config.hookdeckKey) {
throw createError({
status: 401,
});
}
};