Skip to content

Node 18.18.2 : unable to override the Host header in fetch #50305

@fieteboerner

Description

@fieteboerner

Version

v18.18.2

Platform

Linux hostname 5.15.131-1-MANJARO #1 SMP PREEMPT Thu Sep 7 11:05:18 UTC 2023 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

fetch("https://postman-echo.com/get", {
    headers: {
        Test: 1234,
        Host: "foo.postman-echo.com",
    },
})
    .then((r) => {
        return r.text();
    })
    .then((text) => console.log(text))
    .catch((e) => {
        console.log(e);
    });

run this code

The test works successfullty with v18.18.0 & v18.18.0

How often does it reproduce? Is there a required condition?

ive run the tests numerous times
the only condition I know is to run with v18.18.2

What is the expected behavior? Why is that the expected behavior?

  • should send a request topostman-echo.com but should override the Host to foo.postman-echo.com Header
  • the reason: this is how a http client should behave
  • see vor example: curl -H 'Host: foobar.com' https://postman-echo.com/get

What do you see instead?

  • the host header has not been overidden by the headers config
  • the initial set host in the request url is taken

Additional information

  • this was also tested in several docker images
    • node:18-alpine (contains bug)
    • node:18.18.2-alpine (contains bug)
    • node:18.18.2-alpine (no bug)

Metadata

Metadata

Assignees

No one assigned

    Labels

    fetchIssues and PRs related to the Fetch API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions