Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
islazh opened this issue Sep 6, 2024 · 2 comments · Fixed by mswjs/interceptors#627
Closed
4 tasks done
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@islazh
Copy link

islazh commented Sep 6, 2024

Prerequisites

Environment check

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

Node.js version

22.8.0

Reproduction repository

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

Reproduction steps

Steps to reproduce

  • run nvm use
  • run corepack enable
  • run pnpm install
  • run pnpm test

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.

@islazh islazh added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Sep 6, 2024
@kettanaito
Copy link
Member

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 kettanaito changed the title NodeJS native fetch redirect "follow" does not work with MSW redirect handlers Node.js (Undici) fetch doesn't follow redirects when mocked with MSW Sep 7, 2024
@kettanaito
Copy link
Member

Closed in favor of mswjs/interceptors#626. Please follow the updates there.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants