From 30b457fc9824083df797e02db1285609ea42f207 Mon Sep 17 00:00:00 2001 From: Alex Patterson Date: Fri, 23 Oct 2026 14:51:12 -0400 Subject: [PATCH] fix(syndication): use gql-beta.hashnode.com and hashnode-cli headers --- .../functions/syndicate-content/index.ts | 18 +++++++++++------- scripts/run-syndicate-post.mjs | 8 +++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/apps/sanity/functions/syndicate-content/index.ts b/apps/sanity/functions/syndicate-content/index.ts index 345cb9e1..7dccd510 100644 --- a/apps/sanity/functions/syndicate-content/index.ts +++ b/apps/sanity/functions/syndicate-content/index.ts @@ -397,7 +397,7 @@ export const handler = documentEventHandler( slug: `${data._type}-${slug}`, tags: hashnodeTags, ...(hashnodeCoverImageUrl - ? { coverImageOptions: { coverImageURL: hashnodeCoverImageUrl } } + ? { coverImage: hashnodeCoverImageUrl } : {}), originalArticleURL: canonicalUrl, contentMarkdown: `Original: ${canonicalUrl}\n\n${youtubeEmbed}${contentMarkdown}`, @@ -416,14 +416,16 @@ export const handler = documentEventHandler( existingSyndication?.externalId || data.hashnode || null; let publishedPost: { id: string; slug?: string; url?: string } | null = null; + const authHeader = token.startsWith("Bearer ") ? token : `Bearer ${token}`; if (existingHashnodeSlug && !existingHashnodeSlug.startsWith("simulated-")) { // Lookup post ID from Hashnode - const getPostRes = await fetch("https://gql.hashnode.com", { + const getPostRes = await fetch("https://gql-beta.hashnode.com", { method: "POST", headers: { "Content-Type": "application/json", - Authorization: token, + Authorization: authHeader, + "x-hashnode-client": "hashnode-cli", }, body: JSON.stringify({ operationName: "Publication", @@ -445,11 +447,12 @@ export const handler = documentEventHandler( const updateInput = { ...articleInput }; delete updateInput.slug; // slug cannot be updated - const updateRes = await fetch("https://gql.hashnode.com", { + const updateRes = await fetch("https://gql-beta.hashnode.com", { method: "POST", headers: { "Content-Type": "application/json", - Authorization: token, + Authorization: authHeader, + "x-hashnode-client": "hashnode-cli", }, body: JSON.stringify({ operationName: "updatePost", @@ -479,11 +482,12 @@ export const handler = documentEventHandler( if (!publishedPost) { // Create post mutation - const publishRes = await fetch("https://gql.hashnode.com", { + const publishRes = await fetch("https://gql-beta.hashnode.com", { method: "POST", headers: { "Content-Type": "application/json", - Authorization: token, + Authorization: authHeader, + "x-hashnode-client": "hashnode-cli", }, body: JSON.stringify({ operationName: "publishPost", diff --git a/scripts/run-syndicate-post.mjs b/scripts/run-syndicate-post.mjs index 589e5d53..bb9b91ff 100644 --- a/scripts/run-syndicate-post.mjs +++ b/scripts/run-syndicate-post.mjs @@ -248,17 +248,19 @@ async function run() { publicationId, slug: `${doc._type}-${slug}`, tags: hashnodeTags, - ...(hashnodeCoverImageUrl ? { coverImageOptions: { coverImageURL: hashnodeCoverImageUrl } } : {}), + ...(hashnodeCoverImageUrl ? { coverImage: hashnodeCoverImageUrl } : {}), originalArticleURL: canonicalUrl, contentMarkdown: `Original: ${canonicalUrl}\n\n${youtubeEmbed}${contentMarkdown}`, }; try { - const publishRes = await fetch("https://gql.hashnode.com", { + const authHeader = hashnodeToken.startsWith("Bearer ") ? hashnodeToken : `Bearer ${hashnodeToken}`; + const publishRes = await fetch("https://gql-beta.hashnode.com", { method: "POST", headers: { "Content-Type": "application/json", - Authorization: hashnodeToken, + Authorization: authHeader, + "x-hashnode-client": "hashnode-cli", }, body: JSON.stringify({ operationName: "publishPost",