
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see the issue here! Based on the official API CDN documentation, the warning you're seeing is likely not related to authentication at all. Here's what's actually happening:
You correctly noticed that your images are loading from cdn.sanity.io - that's the Asset CDN, which always works through the CDN regardless of your client configuration.
When you run next build (or similar build commands), you're generating static content. During static builds, you should NOT use the CDN - you want the freshest data possible to build your pages. The warning is actually helpful here because it's reminding you that build-time queries should hit the live API, not the cached CDN.
The useCDN option controls whether your GROQ/GraphQL data queries use the cached API CDN (apicdn.sanity.io) or the live API (api.sanity.io).
One important clarification: The API CDN documentation explicitly states that authenticated requests ARE cached on the CDN. They're just "segmented for each unique authentication token." So if you have a token in your client config, it will still use the CDN when useCDN: true is set.
Your setup looks good:
const options = {
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET_NAME,
apiVersion: "2022-01-18",
useCDN: process.env.NEXT_PUBLIC_SANITY_DATASET_NAME === "production", // ✅ Good
};For production runtime: useCDN: true means browser requests will use the fast, cached CDN
For build time: The warning reminds you that builds should use fresh data
The property name is useCdn (lowercase 'n'), not useCDN. While many JavaScript clients accept both due to case-insensitive handling, the canonical form is useCdn. If you're seeing a warning specifically about the casing, try changing:
useCDN: true // might cause a warningto:
useCdn: true // canonical formThe CDN is used for:
useCdn: trueThe CDN is NOT used for:
Your setup is working correctly - the images are on the CDN, and your production client will use the API CDN for data queries at runtime. The build warning is just informing you that during the build process itself, you're hitting the live API for the freshest content.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store