@@ -29,6 +29,7 @@ import * as mime from "mime-types";
2929import { basename } from "path" ;
3030import terminalLink from "terminal-link" ;
3131import { buildTranslatedDocsDefinition } from "./buildTranslatedDocsDefinition.js" ;
32+ import { createGzipFetch , gzipJsonBody } from "./compressedFetch.js" ;
3233import { getDocsDeployMode } from "./docsDeployMode.js" ;
3334import { getDynamicGeneratorConfig } from "./getDynamicGeneratorConfig.js" ;
3435import { measureImageSizes } from "./measureImageSizes.js" ;
@@ -209,10 +210,17 @@ export async function publishDocs({
209210 context . logger . info ( `Docs deploy mode: ${ deployMode } ` ) ;
210211 }
211212
213+ // Capture a gzip-compressing fetch into the oRPC client so all FDR
214+ // requests with a body are transparently compressed. LinkFetchClient
215+ // snapshots globalThis.fetch at construction time, so we swap it in
216+ // before building the client and restore immediately after.
217+ const savedFetch = globalThis . fetch ;
218+ globalThis . fetch = createGzipFetch ( ) ;
212219 const fdr = createFdrService ( {
213220 token : token . value ,
214221 ...( Object . keys ( headers ) . length > 0 && { headers } )
215222 } ) ;
223+ globalThis . fetch = savedFetch ;
216224 const authConfig = { type : "public" as const } ;
217225
218226 if ( excludeApis ) {
@@ -883,24 +891,28 @@ export async function publishDocs({
883891 ) ;
884892 // Use a raw fetch instead of the oRPC client to send `docsDefinition`
885893 // (the live server expects that field; the published fdr-sdk still uses `content`).
894+ const translationPayload = {
895+ domain : translationDomain ,
896+ // Send customDomains in production so FDR fans the translation
897+ // S3 write out across every URL the docs are published to.
898+ // Skipped in preview because preview deploys to a single
899+ // ephemeral URL with no custom-domain mirrors.
900+ customDomains : preview ? [ ] : customDomains ,
901+ orgId : organization ,
902+ locale,
903+ docsDefinition : translatedDefinition
904+ } ;
905+ const compressed = await gzipJsonBody ( translationPayload ) ;
886906 const translationResponse = await fetch ( `${ fdrOrigin } /v2/registry/docs/translations/register` , {
887907 method : "POST" ,
888908 headers : {
889- "Content-Type" : "application/json" ,
909+ ... compressed . headers ,
890910 Authorization : `Bearer ${ token . value } ` ,
891911 ...headers // Include telemetry headers (X-CLI-Version, X-CI-Source, etc.)
892912 } ,
893- body : JSON . stringify ( {
894- domain : translationDomain ,
895- // Send customDomains in production so FDR fans the translation
896- // S3 write out across every URL the docs are published to.
897- // Skipped in preview because preview deploys to a single
898- // ephemeral URL with no custom-domain mirrors.
899- customDomains : preview ? [ ] : customDomains ,
900- orgId : organization ,
901- locale,
902- docsDefinition : translatedDefinition
903- } )
913+ body : compressed . body ,
914+ // @ts -expect-error duplex required for streaming request bodies in Node.js
915+ duplex : "half"
904916 } ) ;
905917 if ( ! translationResponse . ok ) {
906918 const body = await translationResponse . text ( ) ;
0 commit comments