The Sanity engineering blog is live. Deep dives from our engineers.

CORS Origins wildcard subdomain configuration not working

6 repliesLast updated: Nov 29, 2025

Hey! We have a few different domains, and I wanted to add them to the CORS Origins. I'm trying to write
https://*<http://HOSTNAME.se|HOSTNAME.se>
, but I then get CORS error. The actual address I am trying to fit in is:
<https://canary.www.HOSTNAME.se>
. Does anyone know if this is possible or not, and if not: why..?
AI Update

I can see what's happening here! The issue is that Sanity's CORS Origins configuration doesn't support wildcard patterns for subdomains like https://*.HOSTNAME.se. You need to add each specific subdomain individually.

Based on the CORS Origins documentation, here's what you need to know:

Why wildcards don't work: Sanity requires you to explicitly whitelist each complete domain with its full protocol. This is a security best practice to prevent unauthorized access to your content.

What you need to do: For your address https://canary.www.HOSTNAME.se, you need to add the exact, complete URL to your CORS origins:

For multiple domains: If you have several subdomains (like canary.www.HOSTNAME.se, staging.www.HOSTNAME.se, production.www.HOSTNAME.se), you'll need to add each one individually as a separate CORS origin entry. It's a bit more manual work, but it provides better security control over which domains can access your Sanity project.

Important note: The protocol matters! http:// and https:// are treated as different origins, so make sure you're adding the exact protocol you're using.

If you're still getting CORS errors after adding the exact domain, double-check that:

Show original thread
6 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