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
Configure custom matching rules for the mock server. Any request path starting with the value of `prefix` will be proxied to the corresponding target. If the `prefix` value starts with ^, it will be recognized as a RegExp.
138
134
139
135
> In general, `server.proxy` is sufficient to meet the needs. Adding this item is for compatibility with certain scenarios.
140
136
141
137
**Default:**`[]`
142
138
143
139
-`options.wsPrefix`
144
-
140
+
145
141
**Type:**`string | string[]`
146
142
147
143
Configure the matching rules for the WebSocket service. Any request path starting with the value of `wsPrefix` and using the `ws/wss` protocol will be proxied to the corresponding target.
> Different from using `viteConfig.server.proxy` by default for http mock, `websocket mock` does not use the ws-related configuration in `viteConfig.server.proxy`. Also, rules configured in `wsPrefix` cannot be configured simultaneously in `viteConfig.server.proxy`, as it will cause conflicts when starting the vite server because multiple instances of WebSocketServer cannot be implemented for the same request.
152
148
> This conflict is neither a problem with Vite nor with the plugin; it belongs to a reasonable error type. When switching between WebSocket Mock and WebSocket Proxy, please pay attention to avoid duplicate configurations that may cause conflicts.
153
149
154
-
155
-
-`option.include`
150
+
-`option.include`
156
151
157
152
**Type:**`string | string[]`
158
-
153
+
159
154
Configure to read mock files, which can be a directory, glob, or an array.
160
155
161
156
**Default:**`['mock/**/*.mock.{js,ts,cjs,mjs,json,json5}']` (Relative to the root directory.)
162
157
163
158
-`options.exclude`
164
159
165
160
**Type:**`string | string[]`
166
-
161
+
167
162
When reading mock files for configuration, the files that need to be excluded can be a directory, glob, or array.
When the mock resource is hot updated, only the data content is updated, but the page is not refreshed by default. If you want to refresh the page every time you modify the mock file, you can open this option.
176
171
177
172
-`options.cors`
178
-
173
+
179
174
**Type:**`boolean | CorsOptions`
180
175
181
176
Enable by default.
182
177
183
178
Configure to `cors`, see [cors](https://github.com/expressjs/cors#configuration-options)
0 commit comments