Sanity Studio login redirect loop on /desk URL

7 replies
Last updated: Jan 28, 2026
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

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?