Skip to content

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

@islazh

Description

@islazh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds:triageIssues that have not been investigated yet.scope:nodeRelated to MSW running in Node

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions