msw icon indicating copy to clipboard operation
msw copied to clipboard

MSW node does not intercept if I set 'X-Request-Id'

Open cythrawll opened this issue 2 years ago • 0 comments

Prerequisites

Environment check

  • [X] I'm using the latest msw version
  • [X] I'm using Node.js version 18 or higher

Node.js version

v18.16.1

Reproduction repository

https://codesandbox.io/p/devbox/eager-kapitsa-s4cnj7

Reproduction steps

  1. create any handler.
  2. create a call that should hit the handler.
  3. see that it gets intercepted correctly.
  4. Add 'X-Request-Id' header to call with any content.
  5. See the call doesn't get intercepted.

Current behavior

Calls with X-Request-Id header do not get intercepted. This worked in msw 1.x.

https://github.com/mswjs/interceptors/blob/122a6533ce57d551dc3b59b3bb43a39026989b70/src/interceptors/ClientRequest/NodeClientRequest.ts#L193

Expected behavior

Calls with X-Request-Id should be intercepted.

We use that header to pass the request id from the browser request back to the backend for logging purposes. So we would like to intercept those requests. This header is a commonly used header for logging purposes.

cythrawll avatar Dec 18 '23 19:12 cythrawll