Upgrading studio to v3 and encountering hostname issue

3 replies
Last updated: Jan 17, 2024
Hello,I am upgrading a studio from v2 to v3, and have done the necessary steps, however, when deploying my upgraded studio, it is asking me to provide a hostname. This studio is already up and running, and I am hoping I do not need to change the hostname to upgrade to v3. I have not had to do so for any of my other studio upgrades. I am curious if there might be something I am missing or if something has changed.
AI Update

This is likely a configuration file issue that can be easily resolved! When upgrading from Studio v2 to v3, the hostname prompt during deployment typically appears when your sanity.cli.js (or sanity.cli.ts) file is missing the studioHost property.

In Studio v3, the studioHost configuration was introduced to specify the hostname for your Studio deployment. If this property isn't present in your CLI config file, the deployment process will prompt you for it.

The good news: You don't need to change your existing hostname! You can keep using the same one you've been using.

To fix this without being prompted:

Add the studioHost property to your sanity.cli.js or sanity.cli.ts file:

import { defineCliConfig } from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: 'your-project-id',
    dataset: 'your-dataset'
  },
  studioHost: 'your-existing-hostname' // Add this line
})

Or if you're using environment variables:

import { defineCliConfig } from 'sanity/cli'

export default defineCliConfig({
  api: {
    projectId: process.env.SANITY_STUDIO_PROJECT_ID,
    dataset: process.env.SANITY_STUDIO_DATASET
  },
  studioHost: process.env.SANITY_STUDIO_HOSTNAME
})

Your existing hostname is the subdomain part of your current Studio URL (if your Studio is at my-studio.sanity.studio, the hostname is my-studio).

Why this might be different from your other upgrades: It's possible that your other Studios already had this configuration added (perhaps they were upgraded earlier or had different initial setups), or you may have provided the hostname during those deployments and it was cached.

Once you add the studioHost property with your existing hostname, subsequent deployments should proceed without prompting you for it.

Hmm, you shouldn’t have to choose a new hostname. What version of the CLI are you running? Are you sure you have the correct project ID in your config?
Thanks for sending me in the right direction, it wasn’t the project ID in the sanity.config.ts, but the ID in the sanity.cli.ts. Forgot to input it after adding the file and finishing up.Thanks again!
Excellent!

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?