
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a known issue when running Sanity Studio in a monorepo setup with pnpm and Turborepo! The error you're encountering is related to Vite's file system restrictions in monorepo environments.
Since Sanity Studio v3 uses Vite as its build tool, Vite has security restrictions that prevent serving files from outside the workspace root by default. In a monorepo, this becomes problematic because pnpm creates symlinks to shared dependencies in the monorepo root, which Vite blocks by default.
You need to configure Vite's server.fs.allow option in your sanity.config.ts (or .js) file. Add the vite configuration to tell Vite to allow access to your monorepo root:
import {defineConfig} from 'sanity'
import {searchForWorkspaceRoot} from 'vite'
export default defineConfig({
// ... your other config
vite: {
server: {
fs: {
allow: [searchForWorkspaceRoot(process.cwd())]
}
}
}
})The searchForWorkspaceRoot utility from Vite will automatically find your monorepo root (whether it's Turborepo, pnpm workspaces, or Yarn workspaces) and allow Vite to serve files from there.
If you need more control, you can also explicitly specify directories:
import {defineConfig} from 'sanity'
import path from 'path'
export default defineConfig({
// ... your other config
vite: {
server: {
fs: {
allow: [
// Allow serving files from the monorepo root
path.resolve(__dirname, '../..'),
// Or use searchForWorkspaceRoot
// searchForWorkspaceRoot(process.cwd())
]
}
}
}
})The issue is specific to:
When pnpm installs dependencies in a monorepo, it creates symlinks to a shared node_modules at the workspace root. Vite sees these as being outside the "allowed" directory and blocks access, causing the error at localhost:3333.
After adding this configuration, restart your dev server with pnpm run dev and the error should be resolved!
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store