How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Sanity Studio login redirect loop on /desk URL

7 repliesLast updated: Nov 30, 2025

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:

2. Clear Browser Cache and Cookies

Sometimes stale authentication data causes loops:

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

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

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