Skip to content

Export the default server.fs.deny patterns #24015

Open

Description

@rvitaliy

Description

Adding project-specific patterns to server.fs.deny currently requires copying Vite's default list. Setting this option replaces that list entirely, as documented.

For example, our application also denies **/.local/** and **/.env.*/**. To retain Vite's defaults, we duplicate all six default patterns in our configuration and check the copy against Vite during upgrades. The configuration can otherwise miss defaults added by a later release.

Please expose the default patterns through the public Node API so applications can extend the list without maintaining a copy. This request preserves the existing replacement behavior of server.fs.deny.

I have a local implementation with tests and documentation and can submit it as a PR if this API is useful.

Suggested solution

Export a frozen readonly string[], for example defaultServerFsDeny, from vite:

import { defaultServerFsDeny, defineConfig } from 'vite'

export default defineConfig({
  server: {
    fs: {
      deny: [...defaultServerFsDeny, '**/.local/**', '**/.env.*/**'],
    },
  },
})

Use the same constant for Vite's internal defaults, with a separate mutable array for each resolved configuration. Keep custom-only arrays and deny: [] working as they do today.

Alternative

Copying the patterns from the documentation works, but requires tracking changes to that list. Changing deny to append automatically would alter its existing replacement semantics; a public constant would allow explicit composition without a new configuration option.

Additional context

Verified with Vite 8.3.6. The public API already exposes other defaults such as defaultAllowedOrigins and defaultServerConditions.

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions