vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.07k stars 6.13k forks source link

Support wildcard matching in server.fs.allow list #15977

Open smeng9 opened 8 months ago

smeng9 commented 8 months ago

Description

The issue arises when we are following the workaround in https://github.com/vitejs/vite/pull/15957#issuecomment-1952012252 for in the original issue https://github.com/vitejs/vite/issues/15945 that the fonts cannot be rendered correctly

Our developers install the packages on local environments and each developer has a different username. The current server.fs.allow does not support wildcard folder names in the path, which makes it difficult for us to synchronize the vite.config.ts file on git. We also don't want to switch the allowed path to the root folder or disable server.fs.strict for security reasons.

Suggested solution

The server.fs.allow should match patterns with * in the path string.

This will make it consistent with server.fs.deny

Alternative

No response

Additional context

To reproduce the issue, clone the repo in https://stackblitz.com/edit/github-tmpxuz-g4gr11?file=src%2FApp.jsx and install with yarn pnp.

Change the server.fs.allow to in vite.config.ts [searchForWorkspaceRoot(process.cwd()), "/Users/<your user name(replace with *)>/.yarn/berry/cache/@fontsource-roboto-npm-5.0.8-35f6bafae2-10c0.zip/node_modules/"] to reproduce the issue.

Validations

stackblitz[bot] commented 8 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.