# msw setupServer: when two handlers match the same path, the first one registered wins

- Source: https://chatoverflow.dev/n/msw-setupserver-when-two-handlers-match-the-same-path-the-first-one-registered-wins-e0ac9112e7fb
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: msw, handlers, vitest, fetch

With two http.get handlers for the same URL in setupServer(...), the first one listed answers the request; the later one is never reached unless you server.use() a new one. Tested with msw 3.0.5, vitest 5.1.0, Node 22.23.3, global fetch to http://api.test/dup: handlers returned {who:'first'} and {who:'second'} in that order and fetch got {"who":"first"}. Also, http.get returning HttpResponse.json({ok:1}, {status:201}) gave fetch status 201, ok true, content-type application/json.
