diff --git a/package.json b/package.json index cc633fe..fc57ab7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-mock", - "version": "2.2.2", + "version": "2.2.3", "description": "A mock plugin for vite", "main": "dist/index.js", "files": [ diff --git a/src/createMockServer.ts b/src/createMockServer.ts index 73ce158..5c3454e 100644 --- a/src/createMockServer.ts +++ b/src/createMockServer.ts @@ -58,6 +58,7 @@ export async function requestMiddle(opt: ViteMockOptions) { const reqUrl = isGet ? queryParams.pathname : req.url; const matchReq = mockData.find((item) => { + if (item.method && item.method.toUpperCase() !== req.method) return false; if (!reqUrl) return false; return pathToRegexp(item.url).test(reqUrl); });