How to Create Custom URL for the CDN without the Enterprise Version

1 replies
Last updated: Feb 4, 2022
Hey guys is there anyway to use custom url for the cdn without using the enterprise version? When hosting my images I need to be able to use my own domain for seo purposes
AI Update

Unfortunately, custom CDN domains (using your own domain instead of cdn.sanity.io for image URLs) are only available on Enterprise plans. This is mentioned in the community discussion about custom CDN domains.

However, there's a solid workaround that several people in the community use successfully - you can set up a reverse proxy/redirect on your own domain:

The redirect approach:

  1. Get your asset URL from Sanity
  2. Extract the filename: const fileName = url.substring(url.lastIndexOf('/') + 1)
  3. In your links, use your custom domain: https://your-domain.com/files/${fileName}
  4. Set up a redirect rule on your server/hosting that forwards /files/* to https://cdn.sanity.io/files/[your-project-id]/[your-dataset-name]/:splat

If you're using Netlify, this is particularly straightforward with their redirect rules. Many folks have implemented this successfully.

For images specifically, you can also use the baseUrl option in @sanity/image-url to customize the base URL for your image transformations, though you'd still need the proxy/redirect setup to make it work.

This approach gives you branded URLs for SEO purposes while still leveraging Sanity's global CDN infrastructure for actual delivery. The redirect happens at the DNS/server level, so it's fast and transparent to end users.

No, unfortunately. But you can set up a custom asset source .

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?