Skip to content

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Oct 17, 2025

Summary

new Response(JSON.stringify(something), {
  headers: { "Content-Type": "application/json" },
});

// is eequivalent to

Response.json(something);

i.e.

  • no need to JSON.stringify(...)
  • the Content Type is set automatically

Implement this best practice where applicable.

Documentation checklist

@github-actions github-actions bot added product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ product:cloudflare-one product:d1 D1: https://developers.cloudflare.com/d1/ product:durable-objects Durable Objects: https://developers.cloudflare.com/workers/learning/using-durable-objects/ product:hyperdrive Hyperdrive: https://developers.cloudflare.com/hyperdrive/ product:kv product:pages product:pub-sub Pub/Sub: https://developers.cloudflare.com/pub-sub product:r2 R2 object storage: https://developers.cloudflare.com/r2 product:secrets-store product:ssl Related to SSL product:turnstile product:workers Related to Workers product product:workers-ai Workers AI: https://developers.cloudflare.com/workers-ai/ product:zaraz size/m labels Oct 17, 2025
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/agents/ @irvinebroque, @rita3ko, @elithrar, @thomasgauvin, @threepointone, @cloudflare/pcx-technical-writing
/src/content/docs/ai-gateway/ @abhishekkankani, @palashgo, @thebongy, @kathayl, @mchenco, @kodster28, @cloudflare/pcx-technical-writing
/src/content/docs/cloudflare-one/identity/ @kennyj42, @ranbel, @cloudflare/pcx-technical-writing
/src/content/docs/cloudflare-one/ @ranbel, @cloudflare/pcx-technical-writing
/src/content/docs/d1/ @elithrar, @rozenmd, @vy-ton, @joshthoward, @oxyjun, @harshil1712, @cloudflare/pcx-technical-writing
/src/content/docs/durable-objects/ @elithrar, @vy-ton, @joshthoward, @oxyjun, @harshil1712, @mikenomitch, @cloudflare/pcx-technical-writing, @cloudflare/workers-runtime-1
/src/content/docs/hyperdrive/ @elithrar, @thomasgauvin, @sejoker, @oxyjun, @cloudflare/pcx-technical-writing
/src/content/docs/kv/ @elithrar, @thomasgauvin, @rts-rob, @oxyjun, @cloudflare/pcx-technical-writing
/src/content/docs/pages/ @cloudflare/workers-docs, @GregBrimble, @WalshyDev, @aninibread, @irvinebroque, @cloudflare/pcx-technical-writing, @kodster28
/src/content/docs/pub-sub/ @elithrar, @dcpena, @cloudflare/pcx-technical-writing
/src/content/docs/r2/ @oxyjun, @elithrar, @jonesphillip, @aninibread, @harshil1712, @cloudflare/workers-docs, @cloudflare/pcx-technical-writing
/src/content/docs/secrets-store/ @RebeccaTamachiro, @cloudflare/pcx-technical-writing
/src/content/docs/ssl/ @RebeccaTamachiro, @cloudflare/pcx-technical-writing
/src/content/docs/turnstile/ @migueldemoura, @punkeel, @worenga, @patriciasantaana, @cloudflare/pcx-technical-writing
/src/content/docs/workers-ai/ @rita3ko, @craigsdennis, @markdembo, @mchenco, @kodster28, @cloudflare/pcx-technical-writing
/src/content/docs/workers/ @cloudflare/workers-docs, @GregBrimble, @irvinebroque, @mikenomitch, @korinne, @WalshyDev, @cloudflare/deploy-config, @cloudflare/pcx-technical-writing, @kodster28, @cloudflare/wrangler, @cloudflare/workers-runtime-1
/src/content/docs/workers/static-assets @irvinebroque, @GregBrimble, @WalshyDev, @kodster28, @cloudflare/deploy-config, @cloudflare/pcx-technical-writing
/src/content/docs/zaraz/ @ToriLindsay, @kathayl, @bjesus, @jonnyparris, @simonabadoiu, @cloudflare/pcx-technical-writing
/src/content/partials/hyperdrive/ @elithrar, @thomasgauvin, @sejoker, @oxyjun, @cloudflare/pcx-technical-writing

Copy link
Contributor

github-actions bot commented Oct 17, 2025

Preview URL: https://777c24fe.preview.developers.cloudflare.com
Preview Branch URL: https://vicb-resp-json.preview.developers.cloudflare.com

Files with changes (up to 15)

Original Link Updated Link
https://developers.cloudflare.com/workers/examples/cache-tags/ https://vicb-resp-json.preview.developers.cloudflare.com/workers/examples/cache-tags/
https://developers.cloudflare.com/workers/tutorials/postgres/ https://vicb-resp-json.preview.developers.cloudflare.com/workers/tutorials/postgres/
https://developers.cloudflare.com/workers/databases/third-party-integrations/turso/ https://vicb-resp-json.preview.developers.cloudflare.com/workers/databases/third-party-integrations/turso/
https://developers.cloudflare.com/turnstile/tutorials/integrating-turnstile-waf-and-bot-management/ https://vicb-resp-json.preview.developers.cloudflare.com/turnstile/tutorials/integrating-turnstile-waf-and-bot-management/
https://developers.cloudflare.com/workers/databases/third-party-integrations/supabase/ https://vicb-resp-json.preview.developers.cloudflare.com/workers/databases/third-party-integrations/supabase/
https://developers.cloudflare.com/workers/examples/aggregate-requests/ https://vicb-resp-json.preview.developers.cloudflare.com/workers/examples/aggregate-requests/
https://developers.cloudflare.com/ssl/client-certificates/configure-your-mobile-app-or-iot-device/ https://vicb-resp-json.preview.developers.cloudflare.com/ssl/client-certificates/configure-your-mobile-app-or-iot-device/
https://developers.cloudflare.com/agents/api-reference/agents-api/ https://vicb-resp-json.preview.developers.cloudflare.com/agents/api-reference/agents-api/
https://developers.cloudflare.com/d1/best-practices/read-replication/ https://vicb-resp-json.preview.developers.cloudflare.com/d1/best-practices/read-replication/
https://developers.cloudflare.com/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/ https://vicb-resp-json.preview.developers.cloudflare.com/hyperdrive/tutorials/serverless-timeseries-api-with-timescale/
https://developers.cloudflare.com/kv/api/write-key-value-pairs/ https://vicb-resp-json.preview.developers.cloudflare.com/kv/api/write-key-value-pairs/
https://developers.cloudflare.com/workers/examples/modify-request-property/ https://vicb-resp-json.preview.developers.cloudflare.com/workers/examples/modify-request-property/
https://developers.cloudflare.com/durable-objects/examples/alarms-api/ https://vicb-resp-json.preview.developers.cloudflare.com/durable-objects/examples/alarms-api/
https://developers.cloudflare.com/durable-objects/tutorials/build-a-seat-booking-app/ https://vicb-resp-json.preview.developers.cloudflare.com/durable-objects/tutorials/build-a-seat-booking-app/
https://developers.cloudflare.com/zaraz/advanced/context-enricher/ https://vicb-resp-json.preview.developers.cloudflare.com/zaraz/advanced/context-enricher/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

October 2025 product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ product:cloudflare-one product:d1 D1: https://developers.cloudflare.com/d1/ product:durable-objects Durable Objects: https://developers.cloudflare.com/workers/learning/using-durable-objects/ product:hyperdrive Hyperdrive: https://developers.cloudflare.com/hyperdrive/ product:kv product:pages product:pub-sub Pub/Sub: https://developers.cloudflare.com/pub-sub product:r2 R2 object storage: https://developers.cloudflare.com/r2 product:secrets-store product:ssl Related to SSL product:turnstile product:workers Related to Workers product product:workers-ai Workers AI: https://developers.cloudflare.com/workers-ai/ product:zaraz size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.