Discussion about implementing a cname asset domain in Sanity.io

1 replies
Last updated: Apr 15, 2020
Is there a built-in option for a cname asset domain? If not, do you plan on implementing it? For ex. Instead of cdn.sanity.io/ ........ -> assets.example.com/ ...... Currently, this is not very seo friendly 😬
AI Update

Custom asset domains (CNAME for cdn.sanity.io) are available, but they're an Enterprise plan feature. This isn't currently available on the Growth or other lower-tier plans.

From the community discussion, Sanity confirmed that custom domain names (CNAME) for the Asset CDN are available on enterprise plans. So if you need assets.example.com instead of cdn.sanity.io, you'll need to reach out to Sanity's sales team about an Enterprise plan.

Workaround Options

If you're not on an Enterprise plan, there are a couple of practical workarounds:

1. Reverse Proxy/Redirect Approach (recommended for most cases)

You can set up a simple redirect on your hosting platform. For example, on Netlify:

  • Extract the filename from Sanity's asset URL: const fileName = url.substring(url.lastIndexOf('/') + 1)
  • Use your custom domain in links: https://your-domain.com/files/${fileName}
  • Set up a redirect rule: /files/*https://cdn.sanity.io/files/[your-project-id]/[your-dataset-name]/:splat

This approach works well for PDFs and other file assets. For images, you can use the baseUrl option in @sanity/image-url to point to your custom domain.

2. Use Another CDN

You could proxy assets through another CDN service (like Cloudflare, Fastly, etc.) that sits in front of Sanity's Asset CDN, giving you a custom domain while still leveraging Sanity's Asset CDN infrastructure.

SEO Considerations

While having a custom domain can be nice for branding, it's worth noting that using cdn.sanity.io shouldn't negatively impact SEO in most cases. Search engines care more about factors like:

  • Image alt text and context
  • Page load speed (Sanity's CDN is built on Google's global infrastructure)
  • Proper image optimization
  • Overall site authority

The Asset CDN already provides excellent performance with global edge caching, automatic compression (Brotli and Gzip), and content-addressable URLs that enable aggressive browser caching.

If custom asset domains are important for your use case, I'd recommend reaching out to Sanity's sales team to discuss Enterprise plan options.

Hi! That's currently an enterprise feature – if you are interested in learning more you can ping
user H
and he give you more details.

Sanity – Build the way you think, not the way your CMS thinks

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.

Was this answer helpful?