From fdd58de7eabac6c477dfd72322a8cab8ca98c4d4 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 23 Apr 2026 23:47:50 +0200 Subject: [PATCH] fix: use non-cdn client for webhook processing --- nuxt.config.ts | 6 ++++++ server/api/publish-ama.post.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index c76b16c1..426abb1f 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -309,6 +309,12 @@ export default defineNuxtConfig({ sanity: { apiVersion: '2025-02-19', perspective: 'published', + additionalClients: { + // non-CDN client for server-side writes and webhook processing + write: { + useCdn: false, + }, + }, }, scripts: { diff --git a/server/api/publish-ama.post.ts b/server/api/publish-ama.post.ts index b7b58948..708dd8e4 100644 --- a/server/api/publish-ama.post.ts +++ b/server/api/publish-ama.post.ts @@ -136,7 +136,7 @@ export default defineEventHandler(async event => { return { success: false, message: 'Invalid payload or not ready to publish' } } - const sanity = useSanity(event) + const sanity = useSanity(event, 'write') try { const document = await sanity.client.fetch( @@ -668,7 +668,7 @@ async function publishToYouTubeShorts (event: H3Event, document: AMADocument): P console.warn('YouTube Shorts: dereferenced video url missing, falling back to asset lookup', { ref: videoAsset.asset?._ref, }) - const sanity = useSanity(event) + const sanity = useSanity(event, 'write') const videoData = await sanity.client.fetch<{ url?: string } | null>( '*[_id == $id][0]{ url }', { id: videoAsset.asset._ref }, -- 2.54.0