sanity-io / next-sanity

Sanity.io toolkit for Next.js

Home Page:https://www.sanity.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Desk crashes with Uncaught Error: Workspace: missing context value

ilyagru opened this issue · comments

Describe the bug

When embedding the studio into a Next.js app, the desk tool crashes and throws an error "Uncaught Error: Workspace: missing context value". What's interesting is that I have 2 identical projects and one of them works fine, the other crashes with the mentioned error. If I build the studio separately and go to localhost:3333/studio, it doesn't crash.

What could be the issue?

To Reproduce

Steps to reproduce the behavior:

sanity.config.ts

import { defineConfig, isDev } from 'sanity'
import { deskTool } from 'sanity/desk'
import { visionTool } from '@sanity/vision'
import { schemaTypes } from './src/schemas'

export default defineConfig({
  name: 'default',
  title: 'app-studio',
  projectId: '...',
  dataset: 'production',
  basePath: '/studio',
  plugins: [
    deskTool(),
    ...(isDev
      ? [
          visionTool({
            defaultApiVersion: 'v2023-11-02',
            defaultDataset: 'production'
          })
        ]
      : [])
  ],
  schema: {
    types: schemaTypes
  }
})

Expected behavior

No error is thrown.

Screenshots
If applicable, add screenshots to help explain your problem.

Screenshot 2023-11-02 at 11 34 31 Screenshot 2023-11-02 at 11 33 36 Screenshot 2023-11-02 at 11 34 17

Which versions of Sanity are you using?

Sanity v3.19.0
Next.js both v13.5.5 and v14.0.1

What operating system are you using?

macOS 14.1

Which versions of Node.js / npm are you running?

Run npm -v && node -v in the terminal and copy-paste the result here.

Node.js v18.18.2
pnpm v8.10.0

Additional context

Add any other context about the problem here.

Security issue?

Any security issues should be submitted directly to security@sanity.io. In order to determine whether you are dealing with a security issue, ask yourself these two questions:

  • Can I access something that's not mine, or something I shouldn't have access to?
  • Can I disable something for other people? If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just email us at [security@sanity.io](mailto:security@sanity.io.