I have setup a pnpm workspace with a number of projects that I am adding as git submodules.
A previously working Nuxt project suddenly started giving the error The request url * is outside of Vite serving allow list
for multiple files, including dependencies installed as pnpm modules inside the workspace node_modules
folder.
The only change had been to initialise my project as a git repository.
I was expecting the dev server to keep working, and that changes to git would not have any effect.
The project still builds ok.
Vite uses "auto workspace root detection" to figure out where your project root is.
Within a pnpm workspace your project's node_modules
will be installed at the root of the workspace and not within your project folder.
As soon as you initialise a git repository for your project within the workspace then vite seems to auto detect this as your project root and not the workspace (which I'm presuming is initialised as a git repo which you are adding submodules to).
The solution is to specify the pnpm workspace as an allowed directory for the vite server
export default defineNuxtConfig({
vite: {
server: {
fs: {
allow: ["/home/user/Monorepo"]
}
}
}
})