When using the object form of http.request and using an IPv6 address as a hostname, and using a non-standard port, the Host header is created incorrectly...
Example code:
http.request({method: 'GET',hostname: '::1',port:'3000',path: '/api',},(res)=>{console.log(res.statusCode,res.body);}).end()This triggers a HTTP request with:
GET /api HTTP/1.1
Host: ::1:3000
Compared to (for example) curl http://[::1]:3000/api, which does
GET /api HTTP/1.1
Host: [::1]:3000
For reference: https://tools.ietf.org/html/rfc7230#section-5.4
- Kudos to @mpotra for helping me debug this issue..
When using the object form of
http.requestand using an IPv6 address as a hostname, and using a non-standard port, theHostheader is created incorrectly...Example code:
This triggers a HTTP request with:
Compared to (for example)
curl http://[::1]:3000/api, which doesFor reference: https://tools.ietf.org/html/rfc7230#section-5.4