Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: `The request url * is outside of Vite serving allow list` after git init of submodule inside pnpm monorepo workspace

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.

like image 846
Andy2K11 Avatar asked Dec 06 '25 08:12

Andy2K11


2 Answers

The recommended method is to add it to the server.fs.allow list:

import { defineConfig, searchForWorkspaceRoot } from 'vite'
  
export default defineConfig({
  server: {
    fs: {
      allow: [
        // search up for workspace root
        searchForWorkspaceRoot(process.cwd()),
        // your custom rules
        '/path/to/custom/allow',
      ],
    },
  },
})
like image 118
sancelot Avatar answered Dec 09 '25 00:12

sancelot


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"]
            }
        }
    }
})

vite: server-fs-allow

like image 31
Andy2K11 Avatar answered Dec 09 '25 01:12

Andy2K11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!