Skip to content
Discussion options

You must be logged in to vote

Simply delete req.headers.host; before piping to got.

got/source/core/index.ts

Lines 1415 to 1422 in f896aa5

this.on('pipe', source => {
if (source instanceof IncomingMessage) {
this.options.headers = {
...source.headers,
...this.options.headers
};
}
});

Or you can use a beforeRequest hook:

{
    hooks: {
        beforeRequest: [
            options => {
                delete options.headers.host;
            }
        ]
    }
  }
}

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sindresorhus
Comment options

You must be logged in to vote
3 replies
@szmarczak
Comment options

@royalpinto
Comment options

@szmarczak
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1746 on June 08, 2021 08:26.