Skip to content

Commit 03bd025

Browse files
committed
do not pass through the host header
Signed-off-by: Matteo Collina <[email protected]>
1 parent 6fcd6b2 commit 03bd025

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
mysql:
3-
image: mysql:8.0
3+
image: mysql:8
44
container_name: mysql_db
55
restart: always
66
environment:

lib/plugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export async function plugin (server, opts) {
4444
// Php needs capitalized headers
4545
const headers = {}
4646
for (const key of Object.keys(req.headers)) {
47+
if (key === 'host') {
48+
continue
49+
}
4750
const actual = capitalizeHeaders(key)
4851

4952
if (Array.isArray(headers[actual])) {

test/plugin.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ test('get all headers', async t => {
5959

6060
t.assert.deepStrictEqual(res.statusCode, 200)
6161
t.assert.deepStrictEqual(res.json(), {
62-
'HTTP_USER_AGENT': 'lightMyRequest',
63-
'HTTP_HOST': 'localhost:80'
62+
'HTTP_USER_AGENT': 'lightMyRequest'
6463
})
6564
})
6665

0 commit comments

Comments
 (0)