Minor Changes
-
Deprecate
event.context.authin favor ofevent.context.auth()as function (#5513) by @LauraBeatrisexport default clerkMiddleware((event) => { + const { userId } = event.context.auth() - const { userId } = event.context.auth const isAdminRoute = event.path.startsWith('/api/admin') if (!userId && isAdminRoute) { throw createError({ statusCode: 401, statusMessage: 'Unauthorized: User not signed in', }) } }) -
Introduce a
verifyWebhook()function to verify incoming Clerk webhook requests and process the payload. This function handles webhook signature verification usingSvixand is now available across all backend and fullstack SDKs. (#5468) by @wobsorianoTo get started, install
svix, which Clerk uses to verify its webhooks:npm install svix
Then in your webhook route handler, import
verifyWebhook()from the Nuxt SDK:// server/api/webhooks.post.ts import { verifyWebhook } from '@clerk/nuxt/webhooks'; export default eventHandler(async event => { try { const evt = await verifyWebhook(event); // Do something with payload const { id } = evt.data; const eventType = evt.type; console.log(`Received webhook with ID ${id} and event type of ${eventType}`); console.log('Webhook payload:', body); return 'Webhook received'; } catch (err) { console.error('Error: Could not verify webhook:', err); setResponseStatus(event, 400); return 'Error: Verification error'; } });
For more information on how to sync Clerk data to your app with webhooks, see our guide.