Fixing the Vite “outside of Vite serving allow list” Error
If the Vite dev server shows "outside of Vite serving allow list" and images return 403, the file you are loading is outside the folders the dev server is allowed to serve. Add that folder to server.fs.allow in vite.config.ts together with searchForWorkspaceRoot(process.cwd()). The error goes away and the image appears.
For example, this happens when a logo shared by several apps is stored outside the project (in a shared folder in the parent directory) and read from a CSS url(). I reproduced this error in my test environment and included the messages from the terminal and browser as they appeared. I also confirmed that the error disappears after the config change.
The test environment was Ubuntu 24.04, Node.js 22.23.5, and Vite 8.3.8. The project was created from the react-ts template of npm create vite@latest, and I opened the page in Chromium from Playwright 1.63.0. The only files I loaded from outside the project were PNG images read through a CSS url() and a JS import. I did not test other file types such as fonts, Windows or macOS, or pnpm and Yarn workspaces.
- 1. Loading an outside image with a CSS url() returns 403
- 2. Images imported from JS display correctly
- 3. The build does not fail
- 4. Fix it by adding the outside folder to server.fs.allow
- 5. Writing server.fs.allow without searchForWorkspaceRoot removes the project folder from the allow list
- 6. In a monorepo, a parent package.json widens the allowed range
Loading an outside image with a CSS url() returns 403
I used the following layout. app is the Vite project, and shared/brand/logo.png is the shared logo (a 240×80 PNG) stored outside the project. The paths in this article are from my test, where I placed the files under the example path /path/to/.
/path/to/
├── app/ … Vite のプロジェクト
│ ├── src/
│ │ ├── App.tsx
│ │ └── index.css
│ └── vite.config.ts
└── shared/
└── brand/
└── logo.png
I left vite.config.ts as generated by the template. In src/index.css, I set the logo as the background using a relative path.
/* src/index.css */
body { font-family: sans-serif; margin: 24px; }
.banner {
width: 240px;
height: 80px;
background-image: url('../../shared/brand/logo.png');
}
// src/App.tsx
function App() {
return (
<main>
<h1>共通ロゴの表示</h1>
<div className="banner" />
</main>
)
}
export default App
I started the dev server with npx vite and opened it in the browser. The heading appeared, but the area where the logo should be stayed blank. The browser console showed this error:
Failed to load resource: the server responded with a status of 403 (Forbidden)
The request that returned 403 was http://localhost:5173/@fs/path/to/shared/brand/logo.png. Vite serves files outside the project under URLs that start with /@fs/. The terminal running the dev server showed this message:
The request id "/path/to/shared/brand/logo.png" is outside of Vite serving allow list.
- /path/to/app
Refer to docs https://vite.dev/config/server-options.html#server-fs-allow for configurations and more details.
The first line names the file that was refused. The line below it, - /path/to/app, is the allow list: the folders Vite may currently serve. With the template settings, only the project folder is in the list. Each later request for the same file repeated the first line, but the allow list and the docs reference appeared only once.
When I opened the 403 URL directly in the browser, the same message appeared on a page headed "403 Restricted."

Images imported from JS display correctly
When I imported the same logo in App.tsx and displayed it with an <img> element, it appeared without any config change.
import logoUrl from '../../shared/brand/logo.png'
In this case, the logo also appeared as the background of .banner in the CSS, and no message appeared in the terminal. The official description of server.fs.allow says that a file outside the allow list that was not imported from an allowed file returns 403. In the Vite 8.3.8 code, files loaded through a JS import were added to a separate list of readable files, distinct from the allow list.
As a result, two images in the same folder can behave differently: the one imported from JS displays, while the one read only through a CSS url() does not. You can tell whether this error is the cause by checking whether the message above appears in the terminal.
The build does not fail
I ran npx vite build without changing the config. The build finished with no errors or warnings (exit code 0). The logo was copied to dist/assets/logo-C2YYTELE.png, and the built CSS pointed to it.
This error only affects the dev server. If images do not appear on a built and deployed page, look for a different cause.
Fix it by adding the outside folder to server.fs.allow
I added the shared folder to server.fs.allow in vite.config.ts.
// vite.config.ts
import react from '@vitejs/plugin-react'
import { defineConfig, searchForWorkspaceRoot } from 'vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
fs: {
allow: [searchForWorkspaceRoot(process.cwd()), '../shared'],
},
},
})
Relative paths are counted from the project root (app here, where index.html is). I restarted the dev server and reloaded the page. The 403 stopped, and the logo appeared. The terminal showed no messages about the logo. npx tsc -b also passed with the tsconfig from the template (exit code 0).

I also opened a file from another folder that was not in the allow list, and it returned 403 again. The terminal then showed the updated allow list:
- /path/to/app
- /path/to/shared
Allow only the folders you need. The official docs also show allow: ['..'], which allows the whole parent folder. Any file in the parent folder then becomes readable from the dev server, including unrelated ones.
Writing server.fs.allow without searchForWorkspaceRoot removes the project folder from the allow list
I tried allow: ['../shared'] alone, without searchForWorkspaceRoot(process.cwd()). The logo loaded without a 403. However, opening a file inside the project (README.md) at /@fs/path/to/app/README.md returned 403, and the terminal showed this allow list:
- /path/to/shared
- /path/to/app/node_modules/vite/dist/client
/path/to/app, which was present with the template settings, was gone. The official docs also say that writing server.fs.allow stops the automatic selection of the allow list. The second line is a folder Vite adds itself (dist/client inside Vite). In this case the page at / and src/main.tsx still loaded without a 403, so it is easy to miss that the project folder had dropped out. To keep the original range and add to it, write searchForWorkspaceRoot(process.cwd()) alongside your additions.
In a monorepo, a parent package.json widens the allowed range
searchForWorkspaceRoot searches upward from the current folder for the top folder of a monorepo (the workspace root). In the Vite 8.3.8 code, a folder counted as the workspace root if it contained any of the following:
- A
package.jsonwith aworkspacesfield pnpm-workspace.yamlorlerna.jsondeno.jsonordeno.jsoncwith aworkspacefield
If none is found, the nearest folder with a package.json is used, which is the project folder. This is why the allow list contained only /path/to/app with the template settings.
To test this, I restored vite.config.ts to the template version and placed the following in /path/to/package.json, in the parent folder:
{
"private": true,
"workspaces": ["app", "shared"]
}
With only this change and no server.fs.allow setting, the logo loaded without a 403. To see the allow list in this case, I opened a file outside /path/to (/etc/os-release). It returned 403, and the terminal's allow list was just - /path/to. The allowed range became the whole parent folder, and a file in a folder not listed in workspaces also loaded without a 403.
Whether a file is allowed depends on whether it is under the workspace root, not on whether its folder is listed in workspaces. If the shared folder is under that root, it can be read without adding any setting, but so can every other file under the root. If you want a narrower range, add only the folders you need with server.fs.allow.





