mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

Node.js (Undici) fetch doesn't follow redirects when mocked with MSW #2266

Closed islazh closed 2 months ago

islazh commented 2 months ago

Prerequisites

Environment check

Node.js version

22.8.0

Reproduction repository

https://github.com/islazh/msw-redirection-bug-repro

Reproduction steps

Steps to reproduce

Current behavior

The requests do not automatically "follow" the redirect and a 302 is returned in the response with Location header. The test fails as a result.

Expected behavior

The requests should "follow" the redirect and progress to /redirected. The response status should be 200 with whatever HTML is returned.

kettanaito commented 2 months ago

Hi, @islazh. Thanks for reporting this.

Could you please check how is your issue different from #2177? I know you are not using Axios, but I suspect the root cause for this behavior is the same. Thanks.

kettanaito commented 2 months ago

Closed in favor of https://github.com/mswjs/interceptors/issues/626. Please follow the updates there.