Skip to content

Commit 2825d9e

Browse files
committed
Manually add Host header when passed as Array
Notably, when `request#options.headers` is an Array, the `Host` header won't be automatically set. In prior versions of node this wasn't of much consequence, but as of [1] its enforced. [1] nodejs/node#45597
1 parent 9e4a041 commit 2825d9e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/helpers/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ export const req = ({
3939
}
4040

4141
if (Array.isArray(headers)) {
42-
headers = [...Object.entries(bodyHeaders).flat(), ...headers];
42+
headers = [
43+
...Object.entries(bodyHeaders).flat(),
44+
'Host',
45+
`localhost:${port}`,
46+
...headers,
47+
];
4348
} else {
4449
headers = { ...bodyHeaders, ...headers };
4550
}

0 commit comments

Comments
 (0)