msw
msw copied to clipboard
MSW node does not intercept if I set 'X-Request-Id'
Prerequisites
- [X] I confirm my issue is not in the opened issues
- [X] I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- [X] I'm using the latest
mswversion - [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
- create any handler.
- create a call that should hit the handler.
- see that it gets intercepted correctly.
- Add 'X-Request-Id' header to call with any content.
- 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.