
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see you're dealing with a frustrating CORS issue that started after adding/removing tokens. This is a common problem, and the good news is it's usually fixable. Let me break down what's likely happening and how to resolve it.
Based on the CORS documentation, CORS origins in Sanity control which domains can make authenticated requests to your project from browsers. When you mention adding tokens and then seeing CORS errors even after reverting, this suggests the "Allow credentials" setting might be the culprit.
http://localhost:* Works But Hosted Doesn'tThe wildcard port pattern http://localhost:* is valid and will match any port on localhost, which explains why your local development works. However, wildcards with credentials enabled can be problematic for security reasons, and your hosted domains need exact origin matches.
You can manage CORS origins via the Management Console or CLI:
Via Management Console:
Via CLI:
sanity cors list # See what's currently configured
sanity cors delete [ORIGIN] # Remove problematic onesFor each origin, you need to specify:
https://yourdomain.com, not yourdomain.com)Common mistakes:
http:// vs https://Add your hosted domain explicitly:
sanity cors add https://your-actual-domain.com
# When prompted, select YES to allow credentialsOr via the Management Console, making sure to check the "Allow credentials" box.
Go to your project settings and ensure your dataset visibility is set correctly. However, note that even public datasets require CORS configuration for browser-based requests with credentials.
When you added a token to your config, you likely started making authenticated requests. This requires:
The browser security documentation explains that browsers will block requests if the Access-Control-Allow-Credentials header isn't properly set, which is controlled by that checkbox.
https:// not just domain)http://localhost:3000 (specific port) or http://localhost:* (all ports)Once you start making authenticated requests (which tokens enable), the CORS requirements change. Even after removing tokens from your code, if your client is still configured to send credentials, you'll need the CORS origins properly configured with credentials allowed.
If you want to completely reset your CORS configuration via CLI:
# List current origins
sanity cors list
# Delete each one
sanity cors delete http://localhost:3000
sanity cors delete http://localhost:3333
# ... etc
# Add them back with proper credentials
sanity cors add http://localhost:3000
# Select YES when prompted for credentials
sanity cors add https://your-production-domain.com
# Select YES when prompted for credentialsThe key insight here is that wildcards like http://localhost:* are allowed, but for production domains you need exact matches. And critically, if you're using tokens or any form of authentication, you must enable "Allow credentials" for each origin.
If you're still stuck after trying these steps, double-check that your production URL exactly matches what's in the CORS settings (including trailing slashes, subdomains, etc.) - CORS matching is very strict!
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