
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYour issue is a common challenge with Vercel preview deployments and CORS configuration. The problem is that Vercel generates unique URLs for each preview deployment, making it impossible to whitelist them all in advance.
Add your production domain to CORS origins in your Sanity project settings:
https://your-domain.comSince Vercel preview URLs are dynamically generated, here are your best options:
Option 1: Use Server-Side Data Fetching (Recommended) Instead of fetching from the browser (which triggers CORS), fetch data server-side where CORS doesn't apply:
getServerSideProps or getStaticPropsYour Sanity API token stays server-side and never exposes to the browser, which is more secure and performs better.
Option 2: Use a Wildcard Domain with Preview Deployment Suffix
If you have a custom domain on Vercel, configure a Preview Deployment Suffix like preview.example.com. Then add a wildcard to your CORS origins:
https://*.preview.example.comThis gives you a predictable pattern for all preview deployments.
Option 3: Add Vercel's Default Preview Domain Add Vercel's wildcard domain to CORS:
https://*.vercel.app⚠️ Note: This is less secure since it allows any Vercel-hosted site to access your data, but it works for development purposes.
Option 4: Use Vercel's Static Outbound IP Addresses If you're on Vercel's Enterprise plan, you can use static outbound IP addresses for serverless functions and configure IP allowlisting instead of CORS. However, this doesn't solve browser-based CORS issues.
For most projects, Option 1 (server-side fetching) is the best solution. It's more secure, performs better, and works seamlessly across all environments without any CORS configuration. The key insight is that CORS only affects browser requests—server-side requests to Sanity's API don't need CORS configuration at all.
If you absolutely need client-side queries (like for real-time updates with the Live Content API), combine server-side fetching for initial data with Option 2 (custom preview domain wildcard) for client-side updates.
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