Sanity Studio login redirect loop on /desk URL

7 replies
Last updated: Feb 18, 2022
Hello, I am trying to do JavaScript Mastery's video and when I "sanity start" I go to the local host link, log in and then I get sent back to the /desk url to log in again. It's just a never ending loop. I tried opening it with a different user or even a private window but it's still the same. Any suggestions?
AI Update

I've encountered this frustrating login loop issue before, and it's typically related to browser cookie settings or CORS configuration. Here are the solutions that usually work:

Most Common Fixes

1. Check Third-Party Cookie Settings

The most common cause is browser blocking third-party cookies. Sanity Studio authentication relies on cookies to maintain your session. Try these steps:

  • Chrome: Go to Settings → Privacy and Security → Third-party cookies → Allow third-party cookies (or at least add an exception for sanity.io and localhost)
  • Firefox: Settings → Privacy & Security → Enhanced Tracking Protection → Set to "Standard" or add exceptions
  • Safari: Preferences → Privacy → Uncheck "Prevent cross-site tracking" temporarily

2. Clear Browser Cache and Cookies

Sometimes stale authentication data causes loops:

  • Clear all cookies and cache for both localhost:3333 and sanity.io
  • Close all browser tabs/windows
  • Restart your browser completely
  • Try logging in again

3. Try a Different Port

There might be a conflict with port 3333. As mentioned in the localhost:3333 documentation, you can change your Studio port by modifying sanity.cli.ts:

import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
  server: {
    port: 3334, // or any other available port
  },
  // ...other settings
})

Or run: sanity start --port=3334

4. Check Your Project Configuration

Make sure your sanity.config.ts (or sanity.json in older versions) has the correct project ID and dataset name. A mismatch can cause authentication issues.

5. Verify CORS Settings in Sanity Manage

  • Go to manage.sanity.io
  • Select your project
  • Go to Settings → API
  • Under "CORS Origins," make sure http://localhost:3333 is listed (add it with credentials allowed if it's not there)

6. Try Incognito/Private Mode with Relaxed Settings

While you mentioned trying private mode, make sure to temporarily disable any extensions and allow third-party cookies even in private mode for testing.

If none of these work, there might be an issue with your Sanity project setup itself. You could try creating a fresh Sanity project to see if the issue persists, which would help isolate whether it's a configuration problem or a browser/system issue.

The third-party cookie issue is by far the most common culprit for this specific login loop behavior on localhost, so I'd start there first!

Show original thread
7 replies
there's nothing on blocked, everything is on allowed. I can send a screenshot
Thanks for the answer btw
I am also getting the ''connected to dev server'' notification
ah yep, I thought you might be using brave. I know some teammates use it for studio projects and hadn’t tried adjusting this for myself. Thanks for the excuse!
Go settings and search for ‘cookies’. Add your studio url (in development locally it will be
http://localhost:3333 . And for me, since I’m using google oauth for my account, I am allowing 3rd party cookies. Again, you will want to do this again for the new url if you deploy your studio and use this browser:
This fixed it for my dev environment in brave:
You’re welcome to tinker with this settings if you really want to lock down your brave browser’s cookies settings. But you will need to at least allow cookies for your studio url, localhost or hosted on some other url.
perfect, will try that out in a moment. Thank you very much Julia!
aah yes, it worked perfectly! Thanks!

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?