CORS Error: "Unknown network error" connecting to Sanity Studio localhost

20 replies
Last updated: Jan 8, 2023
ISSUE resolved: Extension "HTTPS Everywhere" inside Chrome caused problem. Extension is deprecated as same feature is now available in Chrome Security settings. See also article .
Hello Hello,
after using Sanity last time in September 22 a lot has changed and I'm looking forward to try the new version of Sanity.
Unfortunately I always seem to fail at the simplest step when running
npm run dev
to connect to the sanity studio on my localhost.I updated node, npm, made sure I'm logged into the correct account (locally and web) and that the CORS localhost has full allowance.

Error:
Unknown network error attempting to reach nhj2bb7j.api.sanity.io
The console tells me that the Header Access-Control-Allow-Header has a value not equal to the origin.

I appreciate any hints to solve this error
🙌
AI Update

Great that you resolved it! For anyone else encountering similar CORS-related issues with Sanity Studio, here are the key troubleshooting steps:

Common CORS Configuration Issues

When you see errors like "Unknown network error" or "Access-Control-Allow-Header" issues when connecting to your Sanity Studio on localhost, here's what to check:

1. Verify CORS Origins Settings

Make sure your localhost is properly configured in your CORS settings:

  • Go to manage.sanity.io → Your Project → Settings → API → CORS Origins
  • Add http://localhost:3000 (or whatever port you're using)
  • Important: Enable the "Allow credentials" checkbox if you're using authentication tokens
  • The protocol matters: http:// vs https:// must match exactly

2. Browser Extensions Can Interfere

As you discovered, browser extensions can cause CORS issues even when your configuration is correct. Common culprits include:

  • HTTPS Everywhere (now deprecated - Chrome has this built-in)
  • Privacy/security extensions
  • Ad blockers
  • VPN extensions

Try testing in an incognito/private window to rule out extension interference.

3. Clear Browser Cache

Sometimes stale CORS headers get cached. Try:

  • Hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
  • Clear browser cache
  • Restart your dev server

4. Double-Check Your Project ID

Make sure the project ID in your sanity.config.ts matches the project you've configured CORS for in the Management Dashboard.

5. Local Development Port

If you changed your dev server port, remember to add the new localhost URL to your CORS origins. Each port is treated as a different origin.

The fact that a browser extension was causing this is a good reminder that CORS errors aren't always about your Sanity configuration - sometimes the browser environment itself is the issue! Thanks for sharing the solution - it'll definitely help others who run into the same problem.

Show original thread
20 replies
Hello
user H
👋Did you migrate your studio or did you just update the version?
Hey
user J
I started a new project with a new account and followed the sanity crash course on youtube and get this error.
I haven't migrate my September project yet and wanted to start from scratch first to see what changes have been made.
Which crash course?
link to Youtube
okay, but this still does not tell me anything about YOUR setup 😉 we need to look into that.
What do you mean by setup?
What would you like to know?
I followed this command according to the sanity docs
npx sanity@latest
As far as i understand the docs, this command bypasses the need to install the CLI globally.

I think I still have a global installation from earlier though.

I created a new account with
Sanity.io linked to google.I started a complete new project via VSCode Terminal.
I logged out of sanity before creating a new project.
my Node.js version via Homebrew is 19.3
npm is version 9.2
Sanity CLI states
@sanity/cli version 3.1.2
Yes, but this error as you can see does not occure because of the cli, but because CORS are not set correctly. Did you add https://localhost:3333 and https://localhost:3333 to the list?
And please do not send your responses to the channel 🙏You might have accidentally toggled this
🙂
I just added https to the CORS.No change of error though.
Sorry for the toggle 😅🙈
did you restart your dev server?
Ah and did you setup your client with tokens?
dev server restart -> yesclient with token -> No

Is a token now required?
Could you please show me, which url is open and what the “uncaught in promise” is saying?And btw. you need to make token-ed calls (and use env variables when you dont access your studio from a sanity deployed studio…

https://www.sanity.io/docs/environment-variables
is this helpful?
Hm, are you using a vpn by any chance?
Hello Saskia,Sorry for the late reply.
I'm not using a VPN. Also Double checked my routers settings.

However, I was able to resolve the error.
I tried different browsers and It could connect with Firefox and Safari.
Meaning Chrome was the culprit.
After searching and testing I found the extension "HTTPS Everywhere" to cause this problem.

Disabling it allows me to connect to the Sanity studio now.

Info: Extension deprecated for chrome. Same feature can be activated in Security Settings inside Chrome

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.

Was this answer helpful?