You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/index.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,34 @@ universalApi({
82
82
If the directory doesn't exist, file-based routing will be disabled automatically, but the plugin will still work for custom handlers.
83
83
:::
84
84
85
+
### disablePureFsApi
86
+
87
+
-**Type**: `boolean`
88
+
-**Default**: `false`
89
+
90
+
Disable the **pure File-System API** — the automatic fallback that maps incoming requests directly to files inside `fsDir` when no REST handler matches.
91
+
92
+
When set to `true`, only REST handlers explicitly configured with `handle: "FS"` continue to read files from `fsDir`. Every other unmatched request is handled according to [`noHandledRestFsRequestsAction`](#nohandledrestfsrequestsaction) (default: `"404"`).
93
+
94
+
> **This option does not affect handlers whose `handle` property is `"FS"`**. Those always keep their file-system behaviour, regardless of this flag.
95
+
96
+
```typescript
97
+
universalApi({
98
+
fsDir: 'mock',
99
+
disablePureFsApi: true, // only explicit FS handlers can reach the filesystem
Use `disablePureFsApi: true` when you want explicit control over which endpoints are exposed and want to prevent the plugin from automatically serving any file that happens to exist under `fsDir`.
111
+
:::
112
+
85
113
### enablePreview
86
114
87
115
-**Type**: `boolean`
@@ -452,6 +480,7 @@ export default defineConfig({
452
480
logLevel: 'debug',
453
481
endpointPrefix: '/api',
454
482
fsDir: 'mock',
483
+
disablePureFsApi: false, // set to true to expose only explicit FS handlers
455
484
456
485
// Preview behaviour
457
486
enablePreview: false, // Disable mocks when running vite preview
By default, any request that reaches the plugin and does not match a REST handler is automatically resolved against `fsDir` (the pure File-System API). You can turn off this automatic fallback with the `disablePureFsApi` option.
358
+
359
+
```typescript
360
+
universalApi({
361
+
fsDir: 'mock',
362
+
disablePureFsApi: true, // disable the automatic FS fallback
- Requests that match a handler with `handle: "FS"` are **still served from `fsDir`** as usual.
372
+
- Requests that do **not** match any handler are handled according to `noHandledRestFsRequestsAction` (`"404"` by default) — they are **never** automatically mapped to files.
Use `disablePureFsApi: true` when you want strict, explicit control over which endpoints are exposed and you want to prevent the plugin from automatically serving any file that happens to exist under `fsDir`.
382
+
:::
383
+
355
384
## Limitations
356
385
357
386
- ❌ POST with multiple files not supported (only first file is written)
0 commit comments