
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question about Asset CDN CORS! You've hit a known limitation with Sanity's infrastructure.
The Asset CDN CORS Limitation
According to the CORS Origins documentation, the CORS settings you configure in your Management Dashboard (Settings > API > CORS Origins) apply to the Data API but do not automatically apply to the Asset CDN. This is why you're encountering CORS restrictions when trying to fetch your GeoJSON files directly from the browser—even if you've properly configured CORS for your Data API access.
Recommended Solutions
Sanity Functions are the modern, recommended approach for this scenario. They're serverless functions that run on Sanity's infrastructure and can fetch your asset server-side (where CORS doesn't apply), then serve it to your frontend with proper headers.
Here's the general approach:
Benefits: No external hosting needed, automatic scaling, stays within the Sanity ecosystem, and you control the response headers completely.
For smaller GeoJSON files, consider storing the JSON directly in your document schema instead of as file assets. You can use an object or json field type to store the GeoJSON structure directly in your documents.
Then query it normally with GROQ through the Data API—where your CORS settings work perfectly. This approach works well if:
If you already have a backend server, you can create an endpoint that fetches from the Asset CDN and serves to your frontend. Server-to-server requests don't have CORS restrictions, so your backend can fetch the GeoJSON and add appropriate headers for your frontend.
While not ideal for programmatic fetching, you can use the ?dl query parameter on asset URLs to trigger downloads, though this is more suited for user-initiated downloads rather than JavaScript fetch operations.
Why Functions Are Preferred
For your use case of fetching GeoJSON dynamically, Sanity Functions provide the cleanest solution—they give you full control over headers, don't require external infrastructure, and integrate natively with your Sanity project. The Asset CDN is optimized for direct media delivery (images, videos), while Functions are purpose-built for these kinds of content transformation and delivery scenarios.
Hope this helps! Let me know which approach you end up going with.
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