Issue with deploying Gatsby starter project to Sanity Studio

13 replies
Last updated: May 6, 2021
I've just installed the
kitchen-sink-gatsby
as a starter project, it's been deployed successfully, when I cloned and installed, ran
npm run dev
the web part is working, the studio is just giving me
Cannot GET /
and there are no errors during build.
sanity-studio: Content Studio successfully compiled! Go to <http://localhost:3333>
Any ideas what might be awol here
AI Update

The "Cannot GET /" error you're seeing at http://localhost:3333 is almost certainly a basePath configuration issue. The Studio is compiling successfully, but it's configured to be served at a subpath rather than the root path.

What's happening:

The kitchen-sink-gatsby starter likely has the Studio configured with a basePath (probably /studio), meaning the Studio expects to be accessed at http://localhost:3333/studio instead of just http://localhost:3333. When you visit the root URL, there's nothing there - hence "Cannot GET /".

Quick fix - try these URLs:

  1. http://localhost:3333/studio
  2. http://localhost:3333/admin

One of these should work! The Studio is running fine - you're just accessing the wrong URL.

Finding your basePath:

Check your Studio configuration file. Depending on the Sanity version, look in:

  • Sanity v3: sanity.config.js or sanity.config.ts
  • Sanity v2: sanity.json

Look for a basePath setting:

// In sanity.config.js/ts (v3)
export default defineConfig({
  basePath: '/studio', // <-- This is your path
  // ... other config
})

// Or in sanity.json (v2)
{
  "project": {
    "basepath": "/studio"
  }
}

Solutions:

Option 1: Access the correct URL (easiest) Just use http://localhost:3333/[your-basepath] when opening the Studio.

Option 2: Remove the basePath If you want the Studio at the root:

  • Remove or comment out the basePath line in your config
  • Restart the dev server
  • The Studio will now be at http://localhost:3333

Option 3: Keep the basePath (recommended for Gatsby integration) The basePath is intentional in the kitchen-sink-gatsby starter because it's designed to run alongside your Gatsby site. This is the correct setup for production where both the Gatsby site and Studio are served from the same domain.

Note on Sanity v3: If you're on Sanity v3 and need to configure basePath for both dev and build, you may need to set it in both sanity.config.js AND sanity.cli.js. There was a known issue where the build command didn't respect the basePath from sanity.config.js. The workaround is to add it to sanity.cli.js:

// sanity.cli.js
import { defineCliConfig } from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: 'your-project-id',
    dataset: 'your-dataset',
  },
  project: {
    basePath: '/studio',
  },
})

The "Cannot GET /" message isn't an error - there's just nothing configured to serve at the root path. Your Studio is working perfectly at its configured basePath!

Hi Matt! Could it be that you have anything else running on the same port?
No, at least not that I can tell that’d usually give an error for a conflict port which I don’t get
Do you run
npm run dev
in the repo root?
Yup. I just removed the entire folder, re-cloned, installed and tried again. Same thing 😞
Hm, very strange. Does it work if you
cd
into the studio and start it there?
Tried that too 😞 same issue
Can you send me the result of
node_modules/.bin/sanity start
on DM?
This is the last few lines of the
npm run dev


sanity-kitchen-sink-web:    - while fulfilling desired order of chunk group(s)
warn chunk commons [mini-css-extract-plugin]
sanity-kitchen-sink-web: Conflicting order. Following module has been added:
sanity-kitchen-sink-web:  * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[0].use[1
sanity-kitchen-sink-web: ]!./src/components/typography.module.css
sanity-kitchen-sink-web: despite it was not able to fulfill desired ordering with these modules:
sanity-kitchen-sink-web:  * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[0].use[1
sanity-kitchen-sink-web: ]!./node_modules/gatsby-plugin-postcss/node_modules/postcss-loader/dist/cjs.js??
sanity-kitchen-sink-web: ruleSet[1].rules[9].oneOf[0].use[2]!./src/components/container.module.css
sanity-kitchen-sink-web:    - couldn't fulfill desired order of chunk group(s)
sanity-kitchen-sink-web: component---src-templates-blog-post-js
sanity-kitchen-sink-web:    - while fulfilling desired order of chunk group(s)
success Building development bundle - 14.807s
sanity-kitchen-sink-studio: webpack built 58ae527df407c6ab1f9f in 22500ms
sanity-kitchen-sink-studio: Content Studio successfully compiled! Go to <http://localhost:3333> 
user P
Sure, let me try that now
sanity-kitchen-sink-web
is for the gatsby site,
sanity-kitchen-sink-studio
is printing that it should work 🤔
yeah I know super weird. When I hit the
localhost:3333
I don't see anything in the terminal to indicate a request is being made, and I just get that
Cannot GET /
message in the browser.
With a 404 I assume?
Yup

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?