How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

CORS origins pattern for Cloudflare Pages preview URLs with dynamic hash

7 repliesLast updated: Nov 30, 2025

Hey y’all - I’m wondering if there is a way to set CORs origins for cloudflare pages deploy previews with a URL pattern like this
https://{hash}.domain.pages.dev
where the hash is unique for each PR. Here’s an example from the project we’re working on:
https://444238b5.stylitics-demo-beta.pages.dev
AI Update

Good news! Sanity supports wildcard patterns in CORS origins, which is perfect for handling Cloudflare Pages deploy previews with dynamic hash subdomains.

In your CORS origins configuration (found in manage.sanity.io under Settings > API > CORS Origins), you can add a pattern like:

https://*.stylitics-demo-beta.pages.dev

This wildcard pattern will match all deploy preview URLs like https://444238b5.stylitics-demo-beta.pages.dev, https://abc123ef.stylitics-demo-beta.pages.dev, etc.

Important considerations:

To add these, just go to your project in the Sanity Management Dashboard, navigate to Settings > API > CORS Origins, and add the wildcard pattern. Enable "Allow credentials" if you're using authentication tokens in your Sanity client.

Show original thread
7 replies

Was this answer helpful?

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.

Related contributions