Capítulo 515 de 988
<AvailableFrom v="3. 2.
type NextApiRequest = {
body: object;
headers: Record<string, string>;
};
type NextApiResponse = {
status: (code: number) => {json: (body: object) => void};
};
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
validateWebhookSignature({
secret: process.env.WEBHOOK_SECRET as string,
body: req.body,
signatureHeader: req.headers['x-remotion-signature'] as string,
});
// If code reaches this path, the webhook is authentic.
const payload = req.body as WebhookPayload;
if (payload.type === 'success') {
// ...
} else if (payload.type === 'timeout') {
// ...
}
res.status(200).json({
success: true,
});
}