File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
import type { Server } from 'node:http'
2
2
import type { Http2SecureServer } from 'node:http2'
3
- import { isBoolean , toArray } from '@pengzhanbo/utils'
3
+ import { isBoolean , toArray , uniq } from '@pengzhanbo/utils'
4
4
import cors , { type CorsOptions } from 'cors'
5
5
import { pathToRegexp } from 'path-to-regexp'
6
6
import type { Connect , ResolvedConfig , WebSocketServer } from 'vite'
7
+ import c from 'picocolors'
7
8
import { baseMiddleware } from './baseMiddleware'
8
9
import { viteDefine } from './define'
9
10
import { createLogger } from './logger'
@@ -60,7 +61,11 @@ export function mockServerMiddleware(
60
61
* 但在大多数场景下,共用 `server.proxy` 已足够
61
62
*/
62
63
const prefix = toArray ( options . prefix )
63
- const proxies = [ ...prefix , ...httpProxies ]
64
+ const proxies = uniq ( [ ...prefix , ...httpProxies ] )
65
+
66
+ // #68
67
+ if ( ! proxies . length )
68
+ logger . warn ( `No proxy was configured, mock server will not work. See ${ c . cyan ( 'https://vite-plugin-mock-dev-server.netlify.app/guide/usage' ) } ` )
64
69
65
70
/**
66
71
* 虽然 config.server.proxy 中有关于 ws 的代理配置,
You can’t perform that action at this time.
0 commit comments