From 26d8d4c9db997ddec9acadbe8bd17db747fb6259 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Thu, 17 Oct 2024 17:07:51 +0200 Subject: [PATCH] feat: add .git to deny list by default --- docs/config/server-options.md | 2 +- packages/vite/src/node/server/index.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/config/server-options.md b/docs/config/server-options.md index a1a1d955c83f37..3f389f21fb3515 100644 --- a/docs/config/server-options.md +++ b/docs/config/server-options.md @@ -323,7 +323,7 @@ export default defineConfig({ ## server.fs.deny - **Type:** `string[]` -- **Default:** `['.env', '.env.*', '*.{crt,pem}']` +- **Default:** `['.env', '.env.*', '*.{crt,pem}', '**/.git/**']` Blocklist for sensitive files being restricted to be served by Vite dev server. This will have higher priority than [`server.fs.allow`](#server-fs-allow). [picomatch patterns](https://github.com/micromatch/picomatch#globbing-features) are supported. diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 9927edcf4115aa..29244d0b54b8df 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -1035,7 +1035,12 @@ export function resolveServerOptions( middlewareMode: raw?.middlewareMode || false, } let allowDirs = server.fs?.allow - const deny = server.fs?.deny || ['.env', '.env.*', '*.{crt,pem}'] + const deny = server.fs?.deny || [ + '.env', + '.env.*', + '*.{crt,pem}', + '**/.git/**', + ] if (!allowDirs) { allowDirs = [searchForWorkspaceRoot(root)]